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