js/xpconnect/tests/chrome/test_bug795275.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/tests/chrome/test_bug795275.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     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="chrome://mochikit/content/tests/SimpleTest/test.css"?>
     1.7 +<!--
     1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=795275
     1.9 +-->
    1.10 +<window title="Mozilla Bug 795275"
    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"/>
    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=795275"
    1.17 +     target="_blank">Mozilla Bug 795275</a>
    1.18 +  </body>
    1.19 +
    1.20 +  <!-- test code goes here -->
    1.21 +  <script type="application/javascript">
    1.22 +  <![CDATA[
    1.23 +  /** Test for Warning in content scopes about Components. **/
    1.24 +
    1.25 +  SimpleTest.waitForExplicitFinish();
    1.26 +  SimpleTest.executeSoon(startLoad);
    1.27 +  function startLoad() {
    1.28 +    for (var i = 1; i <= document.getElementsByTagName('iframe').length; ++i) {
    1.29 +      var frame = document.getElementById('frame' + i);
    1.30 +      frame.contentWindow.location = 'http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_bug795275.html';
    1.31 +      frame.onload = frameLoaded;
    1.32 +    }
    1.33 +  }
    1.34 +
    1.35 +  // Set up our console listener.
    1.36 +  var gWarnings = 0;
    1.37 +  function onWarning(consoleMessage) {
    1.38 +    if (/soon be removed/.test(consoleMessage.message))
    1.39 +      gWarnings++;
    1.40 +  }
    1.41 +  var gListener = {
    1.42 +    observe: onWarning,
    1.43 +    QueryInterface: function (iid) {
    1.44 +      if (!iid.equals(Components.interfaces.nsIConsoleListener) &&
    1.45 +          !iid.equals(Components.interfaces.nsISupports)) {
    1.46 +        throw Components.results.NS_ERROR_NO_INTERFACE;
    1.47 +      }
    1.48 +      return this;
    1.49 +    }
    1.50 +  };
    1.51 +  var gConsoleService = Components.classes["@mozilla.org/consoleservice;1"]
    1.52 +                                  .getService(Components.interfaces.nsIConsoleService);
    1.53 +  gConsoleService.registerListener(gListener);
    1.54 +
    1.55 +  // Wait for all four child frame to load.
    1.56 +  var gLoadCount = 0;
    1.57 +  function frameLoaded() {
    1.58 +    if (++gLoadCount == document.getElementsByTagName('iframe').length)
    1.59 +      go();
    1.60 +  }
    1.61 +
    1.62 +  function getWin(id) { return document.getElementById(id).contentWindow.wrappedJSObject; }
    1.63 +  function go() {
    1.64 +    getWin('frame1').touchComponents();
    1.65 +    getWin('frame2').touchInterfaces();
    1.66 +    getWin('frame4').touchComponents();
    1.67 +    getWin('frame4').touchInterfaces();
    1.68 +    // This shouldn't warn.
    1.69 +    getWin('frame5').touchViaXBL();
    1.70 +
    1.71 +    // Warnings are dispatched async, so stick ourselves at the end of the event
    1.72 +    // queue.
    1.73 +    setTimeout(done, 0);
    1.74 +  }
    1.75 +
    1.76 +  function done() {
    1.77 +    gConsoleService.unregisterListener(gListener);
    1.78 +    is(gWarnings, 3, "Got the right number of warnings");
    1.79 +    SimpleTest.finish();
    1.80 +  }
    1.81 +
    1.82 +  ]]>
    1.83 +
    1.84 +  </script>
    1.85 +  <iframe id="frame1"/>
    1.86 +  <iframe id="frame2"/>
    1.87 +  <iframe id="frame3"/>
    1.88 +  <iframe id="frame4"/>
    1.89 +  <iframe id="frame5"/>
    1.90 +
    1.91 +</window>

mercurial