toolkit/content/tests/chrome/test_preferences_beforeaccept.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/test_preferences_beforeaccept.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     1.7 +
     1.8 +<window title="Preferences Window beforeaccept Tests"
     1.9 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.10 +
    1.11 +  <script type="application/javascript"
    1.12 +          src="chrome://mochikit/content/MochiKit/packed.js"/>
    1.13 +  <script type="application/javascript"
    1.14 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.15 +
    1.16 +  <script type="application/javascript">
    1.17 +  <![CDATA[
    1.18 +    SimpleTest.waitForExplicitFinish();
    1.19 +
    1.20 +    // No instant-apply for this test
    1.21 +    SpecialPowers.setBoolPref("browser.preferences.instantApply", false);
    1.22 +
    1.23 +    var prefWindow = openDialog("window_preferences_beforeaccept.xul", "", "", windowOnload);
    1.24 +
    1.25 +    SimpleTest.registerCleanupFunction(() => {
    1.26 +      SpecialPowers.clearUserPref("browser.preferences.instantApply");
    1.27 +      SpecialPowers.clearUserPref("tests.beforeaccept.dialogShown");
    1.28 +      SpecialPowers.clearUserPref("tests.beforeaccept.called");
    1.29 +    });
    1.30 +
    1.31 +    function windowOnload() {
    1.32 +      var dialogShown = prefWindow.document.getElementById("tests.beforeaccept.dialogShown");
    1.33 +      var called = prefWindow.document.getElementById("tests.beforeaccept.called");
    1.34 +      is(dialogShown.value, true, "dialog opened, shown pref set");
    1.35 +      is(dialogShown.valueFromPreferences, null, "shown pref not committed");
    1.36 +      is(called.value, null, "beforeaccept not yet called");
    1.37 +      is(called.valueFromPreferences, null, "beforeaccept not yet called, pref not committed");
    1.38 +
    1.39 +      // try to accept the dialog, should fail the first time
    1.40 +      prefWindow.document.documentElement.acceptDialog();
    1.41 +      is(prefWindow.closed, false, "window not closed");
    1.42 +      is(dialogShown.value, true, "shown pref still set");
    1.43 +      is(dialogShown.valueFromPreferences, null, "shown pref still not committed");
    1.44 +      is(called.value, true, "beforeaccept called");
    1.45 +      is(called.valueFromPreferences, null, "called pref not committed");
    1.46 +
    1.47 +      // try again, this one should succeed
    1.48 +      prefWindow.document.documentElement.acceptDialog();
    1.49 +      is(prefWindow.closed, true, "window now closed");
    1.50 +      is(dialogShown.valueFromPreferences, true, "shown pref committed");
    1.51 +      is(called.valueFromPreferences, true, "called pref committed");
    1.52 +
    1.53 +      SimpleTest.finish();
    1.54 +    }
    1.55 +  ]]>
    1.56 +  </script>
    1.57 +
    1.58 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.59 +    <p id="display"></p>
    1.60 +    <div id="content" style="display: none"></div>
    1.61 +    <pre id="test"></pre>
    1.62 +  </body>
    1.63 +
    1.64 +</window>

mercurial