1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/chrome/test_bug814638.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 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=814638 1.9 +--> 1.10 +<window title="Mozilla Bug 814638" 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=814638" 1.17 + target="_blank" id="link">Mozilla Bug 814638</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 Bug 814638 **/ 1.24 + 1.25 + SimpleTest.waitForExplicitFinish(); 1.26 + 1.27 + function startTest() { 1.28 + let hostURL = "chrome://mochitests/content/chrome/content/base/test/chrome/host_bug814638.xul"; 1.29 + let host1 = window.open(hostURL, "_blank", "chrome"); 1.30 + let host2 = window.open(hostURL, "_blank", "chrome"); 1.31 + 1.32 + let isHost1Loaded = isHost2Loaded = false 1.33 + host1.onload = function() { 1.34 + isHost1Loaded = true; 1.35 + if (isHost2Loaded) swapFrames(); 1.36 + } 1.37 + host2.onload = function() { 1.38 + isHost2Loaded = true; 1.39 + if (isHost1Loaded) swapFrames(); 1.40 + } 1.41 + 1.42 + function swapFrames() { 1.43 + let iframe1 = host1.document.querySelector("iframe"); 1.44 + let iframe2 = host2.document.querySelector("iframe"); 1.45 + iframe2.QueryInterface(Components.interfaces.nsIFrameLoaderOwner); 1.46 + iframe2.swapFrameLoaders(iframe1); 1.47 + setTimeout(function() { 1.48 + iframe2.contentWindow.receivedKeyEvent = receivedKeyEvent; 1.49 + let innerIframe2 = iframe2.contentDocument.querySelector("iframe"); 1.50 + let e = innerIframe2.contentDocument.createEvent("KeyboardEvent"); 1.51 + e.initKeyEvent("keypress", true, true, null, true, false, false, false, 0, "t".charCodeAt(0)); 1.52 + innerIframe2.contentDocument.documentElement.dispatchEvent(e); 1.53 + host1.close(); 1.54 + host2.close(); 1.55 + }, 0); 1.56 + } 1.57 + } 1.58 + 1.59 + function receivedKeyEvent() { 1.60 + ok(true, "Received key event"); 1.61 + SimpleTest.finish(); 1.62 + } 1.63 + 1.64 + addLoadEvent(startTest); 1.65 + ]]> 1.66 + </script> 1.67 +</window>