|
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=814638 |
|
6 --> |
|
7 <window title="Mozilla Bug 814638" |
|
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=814638" |
|
14 target="_blank" id="link">Mozilla Bug 814638</a> |
|
15 </body> |
|
16 |
|
17 <!-- test code goes here --> |
|
18 <script type="application/javascript"> |
|
19 <![CDATA[ |
|
20 /** Test for Bug 814638 **/ |
|
21 |
|
22 SimpleTest.waitForExplicitFinish(); |
|
23 |
|
24 function startTest() { |
|
25 let hostURL = "chrome://mochitests/content/chrome/content/base/test/chrome/host_bug814638.xul"; |
|
26 let host1 = window.open(hostURL, "_blank", "chrome"); |
|
27 let host2 = window.open(hostURL, "_blank", "chrome"); |
|
28 |
|
29 let isHost1Loaded = isHost2Loaded = false |
|
30 host1.onload = function() { |
|
31 isHost1Loaded = true; |
|
32 if (isHost2Loaded) swapFrames(); |
|
33 } |
|
34 host2.onload = function() { |
|
35 isHost2Loaded = true; |
|
36 if (isHost1Loaded) swapFrames(); |
|
37 } |
|
38 |
|
39 function swapFrames() { |
|
40 let iframe1 = host1.document.querySelector("iframe"); |
|
41 let iframe2 = host2.document.querySelector("iframe"); |
|
42 iframe2.QueryInterface(Components.interfaces.nsIFrameLoaderOwner); |
|
43 iframe2.swapFrameLoaders(iframe1); |
|
44 setTimeout(function() { |
|
45 iframe2.contentWindow.receivedKeyEvent = receivedKeyEvent; |
|
46 let innerIframe2 = iframe2.contentDocument.querySelector("iframe"); |
|
47 let e = innerIframe2.contentDocument.createEvent("KeyboardEvent"); |
|
48 e.initKeyEvent("keypress", true, true, null, true, false, false, false, 0, "t".charCodeAt(0)); |
|
49 innerIframe2.contentDocument.documentElement.dispatchEvent(e); |
|
50 host1.close(); |
|
51 host2.close(); |
|
52 }, 0); |
|
53 } |
|
54 } |
|
55 |
|
56 function receivedKeyEvent() { |
|
57 ok(true, "Received key event"); |
|
58 SimpleTest.finish(); |
|
59 } |
|
60 |
|
61 addLoadEvent(startTest); |
|
62 ]]> |
|
63 </script> |
|
64 </window> |