dom/tests/mochitest/bugs/test_bug534149.html

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.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=534149
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 534149</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=534149">Mozilla Bug 534149</a>
michael@0 13 <p id="display"></p>
michael@0 14 <div id="content" style="display: none">
michael@0 15
michael@0 16 </div>
michael@0 17 <pre id="test">
michael@0 18 <script type="application/javascript">
michael@0 19
michael@0 20 /** Test for Bug 534149 **/
michael@0 21 function getIDs(iframe) {
michael@0 22 var win = iframe.contentWindow;
michael@0 23 // Force inner creation
michael@0 24 win.document;
michael@0 25
michael@0 26 var util = SpecialPowers.getDOMWindowUtils(win);
michael@0 27 return [util.outerWindowID, util.currentInnerWindowID];
michael@0 28 }
michael@0 29
michael@0 30 var i1 = document.createElement("iframe");
michael@0 31 var i2 = document.createElement("iframe");
michael@0 32
michael@0 33 document.body.appendChild(i1);
michael@0 34 var [i1outer, i1inner] = getIDs(i1);
michael@0 35
michael@0 36 document.body.appendChild(i2);
michael@0 37 var [i2outer, i2inner] = getIDs(i2);
michael@0 38
michael@0 39 is(i1inner, i1outer + 1, "For frame 1, inner should come right after outer");
michael@0 40 is(i2inner, i2outer + 1, "For frame 2, inner should come right after outer");
michael@0 41 is(i2outer, i1inner + 1, "Frame 2 comes right after frame 1");
michael@0 42
michael@0 43 var innerWindowDestroyID;
michael@0 44 var outerWindowDestroyID;
michael@0 45
michael@0 46 var outerObserver = {
michael@0 47 observe: function(id) {
michael@0 48 outerWindowDestroyID =
michael@0 49 SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
michael@0 50 }
michael@0 51 };
michael@0 52 var innerObserver = {
michael@0 53 observe: function(id) {
michael@0 54 innerWindowDestroyID =
michael@0 55 SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
michael@0 56 }
michael@0 57 };
michael@0 58
michael@0 59 function removeFrame(iframe) {
michael@0 60 SpecialPowers.addObserver(outerObserver, "outer-window-destroyed", false);
michael@0 61 SpecialPowers.addObserver(innerObserver, "inner-window-destroyed", false);
michael@0 62
michael@0 63 iframe.parentNode.removeChild(iframe);
michael@0 64 }
michael@0 65
michael@0 66 removeFrame(i1);
michael@0 67 SimpleTest.waitForExplicitFinish();
michael@0 68 SimpleTest.executeSoon(function() {
michael@0 69 is(innerWindowDestroyID, i1inner, "inner window of frame 1 should be destroyed");
michael@0 70 is(outerWindowDestroyID, i1outer, "outer window of frame 1 should be destroyed");
michael@0 71 SpecialPowers.removeObserver(outerObserver, "outer-window-destroyed");
michael@0 72 SpecialPowers.removeObserver(innerObserver, "inner-window-destroyed");
michael@0 73 SimpleTest.finish();
michael@0 74 });
michael@0 75
michael@0 76
michael@0 77 </script>
michael@0 78 </pre>
michael@0 79 </body>
michael@0 80 </html>

mercurial