This test ensures we can deal with alerts.

!define HTML { {{{
<html>
<body>
<button onclick="confirm('Hello');">Open alert</button>
</body>
</html>}}} }

|script      |mock xml server setup|
|add response|${HTML}              |
|$url=       |get mock server url  |

|storyboard            |browser test    |
|open                  |$url            |
|seconds before timeout|1               |
|check                 |alert text|null |
|click                 |Open alert      |
|check                 |alert text|Hello|
|dismiss alert                          |
|click                 |Open alert      |
|check                 |alert text|Hello|
|confirm alert                          |
|check                 |alert text|null |

!2 Alert from iframe

When we traverse inside iframes and hit an alert we can't go back up the chain to the original frame, because the alert is open.
We have to go back when the alert has been handled.

!define HTML_MAIN { {{{
<html>
<title>Start Page Title</title>
<body>
<input name="remove" type="button" value="Remove">
<iframe id="iframe1" src="frame1.html"></iframe>
</body>
</html>}}} }

!define HTML_FRAME1 { {{{
<html>
<body>
<button onclick="confirm('Hello');">Open alert</button>
<iframe id="iframe1_1" src="frame1_1.html"></iframe>
</body>
</html>}}} }

!define HTML_FRAME2 { {{{
<html>
<body>
<button onclick="confirm('Bye');">Open alert 2</button>
</body>
</html>}}} }


|script      |mock xml server setup                              |
|add response|${HTML_MAIN}                                       |
|add response|${HTML_FRAME1}|for|GET: /FitNesseMock/frame1.html  |
|add response|${HTML_FRAME2}|for|GET: /FitNesseMock/frame1_1.html|
|$url=       |get mock server url                                |

|script                |browser test                                                      |
|open                  |$url/main                                                         |
|seconds before timeout|2                                                                 |
|check                 |alert text                             |null                      |
|click                 |Open alert 2                                                      |
|check                 |alert text                             |Bye                       |
|confirm alert                                                                            |
|note                  |we should be able to click Remove because we are back at top level|
|click                 |Remove                                                            |
|switch to frame       |id=iframe1                                                        |
|click                 |Open alert 2                                                      |
|check                 |alert text                             |Bye                       |
|dismiss alert                                                                            |
|note                  |we should be unable to click Remove because we are back at level 1|
|reject                |click if available                     |Remove                    |
|switch to default content                                                                |
|click                 |Open alert                                                        |
|check                 |alert text                             |Hello                     |
|dismiss alert                                                                            |
|note                  |we should be able to click Remove because we are back at top level|
|click                 |Remove                                                            |


|script|mock xml server setup|
|stop                        |

