dom/tests/mochitest/chrome/test_popup_blocker_chrome.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/chrome/test_popup_blocker_chrome.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
     1.6 +<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
     1.7 +<!--
     1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=662519
     1.9 +-->
    1.10 +<window title="Mozilla Bug 662519"
    1.11 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +
    1.14 +  <!-- test results are displayed in the html:body -->
    1.15 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.16 +  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=662519"
    1.17 +     target="_blank">Mozilla Bug 662519</a>
    1.18 +  </body>
    1.19 +
    1.20 +  <!-- test code goes here -->
    1.21 +  <script type="application/javascript">
    1.22 +  <![CDATA[
    1.23 +
    1.24 +  /** Test for Bug 662519 **/
    1.25 +
    1.26 +  SimpleTest.waitForExplicitFinish();
    1.27 +
    1.28 +  // We have to enable dom.disable_open_during_load which is disabled
    1.29 +  // by the test harness.
    1.30 +  let prefs = Components.classes["@mozilla.org/preferences-service;1"]
    1.31 +                .getService(Components.interfaces.nsIPrefBranch);
    1.32 +  var gLastDomLoadValue = prefs.getBoolPref("dom.disable_open_during_load");
    1.33 +  prefs.setBoolPref("dom.disable_open_during_load", true);
    1.34 +
    1.35 +  let w = window.open("data:text/html,foobar", "", "width=200,height=200");
    1.36 +  ok(w, "The window object shouldn't be null");
    1.37 +
    1.38 +  SimpleTest.waitForFocus(function() {
    1.39 +    w.close();
    1.40 +    ok(true, "The popup appeared");
    1.41 +
    1.42 +    SimpleTest.waitForFocus(function() {
    1.43 +      let w = window.open("data:text/html,foobar", "", "width=200,height=200");
    1.44 +      ok(w, "The window object shouldn't be null");
    1.45 +
    1.46 +      SimpleTest.waitForFocus(function() {
    1.47 +        w.close();
    1.48 +
    1.49 +        ok(true, "The popup appeared");
    1.50 +        prefs.setBoolPref("dom.disable_open_during_load", gLastDomLoadValue);
    1.51 +        SimpleTest.finish();
    1.52 +      }, w, false);
    1.53 +    });
    1.54 +  }, w, false);
    1.55 +  ]]>
    1.56 +  </script>
    1.57 +</window>

mercurial