test_bug1412775.xhtml (2703B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?> 3 <?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?> 4 <!-- 5 https://bugzilla.mozilla.org/show_bug.cgi?id=1412775 6 --> 7 <window title="Mozilla Bug 1412775" 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 9 onload="init()"> 10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 11 <script src="chrome://mochikit/content/chrome-harness.js"></script> 12 13 <!-- test code goes here --> 14 <script type="application/javascript"> 15 <![CDATA[ 16 17 /** Test for Bug 1412775 */ 18 var win; 19 function init() { 20 SimpleTest.waitForExplicitFinish(); 21 win = window.browsingContext.topChromeWindow.open("window_bug1412775.xhtml", "_new", "chrome"); 22 win.onload = function() { 23 var b = win.document.getElementById("browser"); 24 var d = b.contentWindow.document; 25 var e = new d.defaultView.Event("foo"); 26 var didCallChromeSide = false; 27 var didCallContentSide = false; 28 /* eslint-disable-next-line no-shadow */ 29 b.addEventListener("foo", function(e) { 30 didCallChromeSide = true; 31 var path = e.composedPath(); 32 var mm = d.defaultView.docShell.messageManager; 33 is(path.length, 5, "Should have 5 items in composedPath in chrome."); 34 is(path[0], mm, "BrowserChildGlobal is the chrome handler."); 35 is(path[1], b, "browser element should be in the path."); 36 is(path[2], b.parentNode, "window element should be in the path."); 37 is(path[3], win.document, "Document object should be in the path."); 38 is(path[4], win, "Window object should be in the path."); 39 }, true, true); 40 /* eslint-disable-next-line no-shadow */ 41 d.addEventListener("foo", function(e) { 42 didCallContentSide = true;; 43 var path = e.composedPath(); 44 is(path.length, 4, "Should have 4 items in composedPath in content."); 45 is(path[0], d.body, "body element should be in the path."); 46 is(path[1], d.documentElement, "html element should be in the path."); 47 is(path[2], d, "Document object should be in the path."); 48 is(path[3], d.defaultView, "Window object should be in the path."); 49 }, true, true); 50 d.body.dispatchEvent(e); 51 ok(didCallChromeSide, "didCallChromeSide"); 52 ok(didCallContentSide, "didCallContentSide"); 53 win.close(); 54 SimpleTest.finish(); 55 } 56 } 57 58 ]]> 59 </script> 60 61 <!-- test results are displayed in the html:body --> 62 <body xmlns="http://www.w3.org/1999/xhtml"> 63 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1412775" 64 target="_blank">Mozilla Bug 1412775</a> 65 </body> 66 </window>