|
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=773962 |
|
6 --> |
|
7 <window title="Mozilla Bug 773962" |
|
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"/> |
|
10 |
|
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=773962" |
|
14 target="_blank">Mozilla Bug 773962</a> |
|
15 </body> |
|
16 |
|
17 <!-- test code goes here --> |
|
18 <script type="application/javascript"> |
|
19 <![CDATA[ |
|
20 |
|
21 /** Test for remapping Xray waivers during brain transplant. **/ |
|
22 SimpleTest.waitForExplicitFinish(); |
|
23 const Cu = Components.utils; |
|
24 |
|
25 var gFramesLoaded = 0; |
|
26 function frameLoaded() { |
|
27 ++gFramesLoaded; |
|
28 if (gFramesLoaded == 2) |
|
29 startTest(); |
|
30 if (gFramesLoaded == 3) |
|
31 finishTest(); |
|
32 } |
|
33 |
|
34 function startTest() { |
|
35 // grab the windows and the node. |
|
36 win1 = document.getElementById('frame1').contentWindow; |
|
37 win2 = document.getElementById('frame2').contentWindow; |
|
38 node1 = win1.document.getElementById('text'); |
|
39 loc1 = win1.location; |
|
40 |
|
41 // Grab some Xray waivers. |
|
42 win1Waiver = win1.wrappedJSObject; |
|
43 node1Waiver = node1.wrappedJSObject; |
|
44 loc1Waiver = win1Waiver.location; |
|
45 |
|
46 // Adopt node1 into win2. This causes node1 to be transplanted. |
|
47 win2.document.adoptNode(node1); |
|
48 |
|
49 // Navigate win1. This causes win1 to be transplanted. |
|
50 win1.location = 'http://test2.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html'; |
|
51 |
|
52 // The above happens async. Our onload handler will call finishTest() when we're ready. |
|
53 } |
|
54 |
|
55 function finishTest() { |
|
56 // Now, recompute some wrappers. |
|
57 Cu.recomputeWrappers(); |
|
58 |
|
59 // First, pat ourselves on the back for not asserting/crashing. That's most of |
|
60 // what we're really testing here. |
|
61 ok(true, "Didnt crash!"); |
|
62 |
|
63 // Now, make sure everything is set up how we expect. |
|
64 ok(win1Waiver === win1.wrappedJSObject, "waivers still work"); |
|
65 ok(XPCNativeWrapper(win1Waiver) === win1, "waivers still work"); |
|
66 ok(node1Waiver === node1.wrappedJSObject, "waivers still work"); |
|
67 ok(XPCNativeWrapper(node1Waiver) === node1, "waivers still work"); |
|
68 |
|
69 // The semantics of location are tricky, because win1 now has a new location object. |
|
70 // In fact, loc1 should be a dead object proxy. Let's make sure we get this right. |
|
71 ok(loc1 !== win1.location, "navigation means different window.location"); |
|
72 ok(loc1Waiver !== win1.location.wrappedJSObject, "navigation means different window.location"); |
|
73 |
|
74 // Whew. |
|
75 SimpleTest.finish(); |
|
76 } |
|
77 |
|
78 ]]> |
|
79 </script> |
|
80 <iframe id="frame1" onload="frameLoaded();" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" /> |
|
81 <iframe id="frame2" onload="frameLoaded();" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" /> |
|
82 </window> |