|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
4 |
|
5 <window title="Preferences Window beforeaccept Tests" |
|
6 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
7 |
|
8 <script type="application/javascript" |
|
9 src="chrome://mochikit/content/MochiKit/packed.js"/> |
|
10 <script type="application/javascript" |
|
11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
|
12 |
|
13 <script type="application/javascript"> |
|
14 <![CDATA[ |
|
15 SimpleTest.waitForExplicitFinish(); |
|
16 |
|
17 // No instant-apply for this test |
|
18 SpecialPowers.setBoolPref("browser.preferences.instantApply", false); |
|
19 |
|
20 var prefWindow = openDialog("window_preferences_beforeaccept.xul", "", "", windowOnload); |
|
21 |
|
22 SimpleTest.registerCleanupFunction(() => { |
|
23 SpecialPowers.clearUserPref("browser.preferences.instantApply"); |
|
24 SpecialPowers.clearUserPref("tests.beforeaccept.dialogShown"); |
|
25 SpecialPowers.clearUserPref("tests.beforeaccept.called"); |
|
26 }); |
|
27 |
|
28 function windowOnload() { |
|
29 var dialogShown = prefWindow.document.getElementById("tests.beforeaccept.dialogShown"); |
|
30 var called = prefWindow.document.getElementById("tests.beforeaccept.called"); |
|
31 is(dialogShown.value, true, "dialog opened, shown pref set"); |
|
32 is(dialogShown.valueFromPreferences, null, "shown pref not committed"); |
|
33 is(called.value, null, "beforeaccept not yet called"); |
|
34 is(called.valueFromPreferences, null, "beforeaccept not yet called, pref not committed"); |
|
35 |
|
36 // try to accept the dialog, should fail the first time |
|
37 prefWindow.document.documentElement.acceptDialog(); |
|
38 is(prefWindow.closed, false, "window not closed"); |
|
39 is(dialogShown.value, true, "shown pref still set"); |
|
40 is(dialogShown.valueFromPreferences, null, "shown pref still not committed"); |
|
41 is(called.value, true, "beforeaccept called"); |
|
42 is(called.valueFromPreferences, null, "called pref not committed"); |
|
43 |
|
44 // try again, this one should succeed |
|
45 prefWindow.document.documentElement.acceptDialog(); |
|
46 is(prefWindow.closed, true, "window now closed"); |
|
47 is(dialogShown.valueFromPreferences, true, "shown pref committed"); |
|
48 is(called.valueFromPreferences, true, "called pref committed"); |
|
49 |
|
50 SimpleTest.finish(); |
|
51 } |
|
52 ]]> |
|
53 </script> |
|
54 |
|
55 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
56 <p id="display"></p> |
|
57 <div id="content" style="display: none"></div> |
|
58 <pre id="test"></pre> |
|
59 </body> |
|
60 |
|
61 </window> |