Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | |
michael@0 | 4 | <window id="303267Test" |
michael@0 | 5 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 6 | width="600" |
michael@0 | 7 | height="600" |
michael@0 | 8 | onload="nextTestAsync();" |
michael@0 | 9 | title="bug 582176 test"> |
michael@0 | 10 | |
michael@0 | 11 | <script type="text/javascript" |
michael@0 | 12 | src="chrome://mochikit/content/tests/SimpleTest/specialpowersAPI.js"/> |
michael@0 | 13 | <script type="text/javascript" |
michael@0 | 14 | src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/> |
michael@0 | 15 | <script type="text/javascript" |
michael@0 | 16 | src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/> |
michael@0 | 17 | <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" /> |
michael@0 | 18 | <script type="application/javascript" src="docshell_helpers.js" /> |
michael@0 | 19 | <script type="application/javascript"><![CDATA[ |
michael@0 | 20 | |
michael@0 | 21 | // Define the generator-iterator for the tests. |
michael@0 | 22 | var tests = testIterator(); |
michael@0 | 23 | |
michael@0 | 24 | //// |
michael@0 | 25 | // Execute the next test in the generator function. |
michael@0 | 26 | // |
michael@0 | 27 | function nextTestAsync() { |
michael@0 | 28 | SimpleTest.executeSoon(tests.next.bind(tests)); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | //// |
michael@0 | 32 | // Generator function for test steps for bug 582176: |
michael@0 | 33 | // Description goes here. |
michael@0 | 34 | // |
michael@0 | 35 | function testIterator() |
michael@0 | 36 | { |
michael@0 | 37 | var browser = document.getElementById('content'); |
michael@0 | 38 | browser.addEventListener("pageshow", nextTestAsync, true); |
michael@0 | 39 | |
michael@0 | 40 | enableBFCache(true); |
michael@0 | 41 | |
michael@0 | 42 | var notificationCount = 0; |
michael@0 | 43 | var observer = { |
michael@0 | 44 | observe: function(aSubject, aTopic, aData) { |
michael@0 | 45 | is(aSubject, browser.contentWindow, |
michael@0 | 46 | "correct subject"); |
michael@0 | 47 | is(aTopic, "content-document-global-created", |
michael@0 | 48 | "correct topic"); |
michael@0 | 49 | is(aData, "http://mochi.test:8888", |
michael@0 | 50 | "correct data"); |
michael@0 | 51 | notificationCount++; |
michael@0 | 52 | } |
michael@0 | 53 | }; |
michael@0 | 54 | |
michael@0 | 55 | os = Components.classes["@mozilla.org/observer-service;1"]. |
michael@0 | 56 | getService(Components.interfaces.nsIObserverService); |
michael@0 | 57 | os.addObserver(observer, "content-document-global-created", false); |
michael@0 | 58 | |
michael@0 | 59 | browser.loadURI("http://mochi.test:8888/tests/docshell/test/chrome/582176_dummy.html"); |
michael@0 | 60 | yield undefined; |
michael@0 | 61 | is(browser.contentWindow.testVar, undefined, |
michael@0 | 62 | "variable unexpectedly there already"); |
michael@0 | 63 | browser.contentWindow.wrappedJSObject.testVar = 1; |
michael@0 | 64 | is(notificationCount, 1, "Should notify on first navigation"); |
michael@0 | 65 | |
michael@0 | 66 | browser.loadURI("http://mochi.test:8888/tests/docshell/test/chrome/582176_dummy.html?2"); |
michael@0 | 67 | yield undefined; |
michael@0 | 68 | is(browser.contentWindow.wrappedJSObject.testVar, undefined, |
michael@0 | 69 | "variable should no longer be there"); |
michael@0 | 70 | is(notificationCount, 2, "Should notify on second navigation"); |
michael@0 | 71 | |
michael@0 | 72 | browser.goBack(); |
michael@0 | 73 | yield undefined; |
michael@0 | 74 | is(browser.contentWindow.wrappedJSObject.testVar, 1, |
michael@0 | 75 | "variable should still be there"); |
michael@0 | 76 | is(notificationCount, 2, "Should not notify on back navigation"); |
michael@0 | 77 | |
michael@0 | 78 | browser.loadURI("http://mochi.test:8888/tests/docshell/test/chrome/582176_xml.xml"); |
michael@0 | 79 | yield undefined; |
michael@0 | 80 | is(browser.contentDocument.body.textContent, "xslt result", |
michael@0 | 81 | "Transform performed successfully"); |
michael@0 | 82 | is(notificationCount, 3, "Should notify only once on XSLT navigation"); |
michael@0 | 83 | |
michael@0 | 84 | os.removeObserver(observer, "content-document-global-created") |
michael@0 | 85 | |
michael@0 | 86 | // Tell the framework the test is finished. Include the final 'yield' |
michael@0 | 87 | // statement to prevent a StopIteration exception from being thrown. |
michael@0 | 88 | finish(); |
michael@0 | 89 | yield undefined; |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | ]]></script> |
michael@0 | 93 | <browser type="content-primary" flex="1" id="content" src="about:blank"/> |
michael@0 | 94 | </window> |