js/xpconnect/tests/chrome/test_bug795275.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
     3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
     4 <!--
     5 https://bugzilla.mozilla.org/show_bug.cgi?id=795275
     6 -->
     7 <window title="Mozilla Bug 795275"
     8         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     9   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    11   <!-- test results are displayed in the html:body -->
    12   <body xmlns="http://www.w3.org/1999/xhtml">
    13   <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=795275"
    14      target="_blank">Mozilla Bug 795275</a>
    15   </body>
    17   <!-- test code goes here -->
    18   <script type="application/javascript">
    19   <![CDATA[
    20   /** Test for Warning in content scopes about Components. **/
    22   SimpleTest.waitForExplicitFinish();
    23   SimpleTest.executeSoon(startLoad);
    24   function startLoad() {
    25     for (var i = 1; i <= document.getElementsByTagName('iframe').length; ++i) {
    26       var frame = document.getElementById('frame' + i);
    27       frame.contentWindow.location = 'http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_bug795275.html';
    28       frame.onload = frameLoaded;
    29     }
    30   }
    32   // Set up our console listener.
    33   var gWarnings = 0;
    34   function onWarning(consoleMessage) {
    35     if (/soon be removed/.test(consoleMessage.message))
    36       gWarnings++;
    37   }
    38   var gListener = {
    39     observe: onWarning,
    40     QueryInterface: function (iid) {
    41       if (!iid.equals(Components.interfaces.nsIConsoleListener) &&
    42           !iid.equals(Components.interfaces.nsISupports)) {
    43         throw Components.results.NS_ERROR_NO_INTERFACE;
    44       }
    45       return this;
    46     }
    47   };
    48   var gConsoleService = Components.classes["@mozilla.org/consoleservice;1"]
    49                                   .getService(Components.interfaces.nsIConsoleService);
    50   gConsoleService.registerListener(gListener);
    52   // Wait for all four child frame to load.
    53   var gLoadCount = 0;
    54   function frameLoaded() {
    55     if (++gLoadCount == document.getElementsByTagName('iframe').length)
    56       go();
    57   }
    59   function getWin(id) { return document.getElementById(id).contentWindow.wrappedJSObject; }
    60   function go() {
    61     getWin('frame1').touchComponents();
    62     getWin('frame2').touchInterfaces();
    63     getWin('frame4').touchComponents();
    64     getWin('frame4').touchInterfaces();
    65     // This shouldn't warn.
    66     getWin('frame5').touchViaXBL();
    68     // Warnings are dispatched async, so stick ourselves at the end of the event
    69     // queue.
    70     setTimeout(done, 0);
    71   }
    73   function done() {
    74     gConsoleService.unregisterListener(gListener);
    75     is(gWarnings, 3, "Got the right number of warnings");
    76     SimpleTest.finish();
    77   }
    79   ]]>
    81   </script>
    82   <iframe id="frame1"/>
    83   <iframe id="frame2"/>
    84   <iframe id="frame3"/>
    85   <iframe id="frame4"/>
    86   <iframe id="frame5"/>
    88 </window>

mercurial