test_bug608669.xhtml (2378B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 4 <!-- 5 https://bugzilla.mozilla.org/show_bug.cgi?id=608669 6 --> 7 <window title="Mozilla Bug 608669" 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 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=608669" 14 target="_blank">Mozilla Bug 608669</a> 15 </body> 16 17 <!-- test code goes here --> 18 <script type="application/javascript"><![CDATA[ 19 20 /** Test for Bug 608669 */ 21 SimpleTest.waitForExplicitFinish(); 22 23 addLoadEvent(nextTest); 24 25 let gen = doTest(); 26 27 function nextTest() { 28 gen.next(); 29 } 30 31 let chromeWindow = window.browsingContext.topChromeWindow; 32 33 function* doTest() { 34 var notificationCount = 0; 35 var observer = { 36 observe(aSubject, aTopic, aData) { 37 is(aTopic, "chrome-document-global-created", 38 "correct topic"); 39 is(aData, "null", 40 "correct data"); 41 notificationCount++; 42 } 43 }; 44 45 var os = SpecialPowers.Services.obs; 46 os.addObserver(observer, "chrome-document-global-created"); 47 os.addObserver(observer, "content-document-global-created"); 48 49 is(notificationCount, 0, "initial count"); 50 51 // create a new window 52 var testWin = chromeWindow.open("bug608669.xhtml", "bug 608669", "chrome,width=600,height=600"); 53 // Synchronously modify the transient about:blank window 54 testWin.x = "y"; 55 is(testWin.location.href, 'about:blank'); 56 is(notificationCount, 0, "after created window"); 57 58 // Wait for the window to load 59 chromeWindow.onmessage = nextTest; 60 yield undefined; 61 is(notificationCount, 1, "after first load"); 62 is(testWin.x, "y", "reused window"); 63 64 // Try loading again in the window 65 testWin.location = "bug608669.xhtml?x"; 66 chromeWindow.onmessage = nextTest; 67 yield undefined; 68 is(notificationCount, 2, "after second load"); 69 is("x" in testWin, false, "didn't reuse window"); 70 71 chromeWindow.onmessage = null; 72 73 testWin.close(); 74 75 os.removeObserver(observer, "chrome-document-global-created"); 76 os.removeObserver(observer, "content-document-global-created"); 77 SimpleTest.finish(); 78 } 79 80 ]]></script> 81 </window>