CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / docshell / test / chrome / bug582176_window.xul
blob7ba3aa075eca727e76ba59136b56d021f28ecba2
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
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">
11 <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
12 <script type="application/javascript" src="docshell_helpers.js" />
13 <script type="application/javascript"><![CDATA[
15 // Define the generator-iterator for the tests.
16 var tests = testIterator();
18 ////
19 // Execute the next test in the generator function.
21 function nextTestAsync() {
22 SimpleTest.executeSoon(tests.next.bind(tests));
25 ////
26 // Generator function for test steps for bug 582176:
27 // Description goes here.
29 function testIterator()
31 var browser = document.getElementById('content');
32 browser.addEventListener("pageshow", nextTestAsync, true);
34 enableBFCache(true);
36 var notificationCount = 0;
37 var observer = {
38 observe: function(aSubject, aTopic, aData) {
39 is(aSubject, browser.contentWindow,
40 "correct subject");
41 is(aTopic, "content-document-global-created",
42 "correct topic");
43 is(aData, "http://mochi.test:8888",
44 "correct data");
45 notificationCount++;
49 os = Components.classes["@mozilla.org/observer-service;1"].
50 getService(Components.interfaces.nsIObserverService);
51 os.addObserver(observer, "content-document-global-created", false);
53 browser.loadURI("http://mochi.test:8888/tests/docshell/test/chrome/582176_dummy.html");
54 yield;
55 is(browser.contentWindow.testVar, undefined,
56 "variable unexpectedly there already");
57 browser.contentWindow.wrappedJSObject.testVar = 1;
58 is(notificationCount, 1, "Should notify on first navigation");
60 browser.loadURI("http://mochi.test:8888/tests/docshell/test/chrome/582176_dummy.html?2");
61 yield;
62 is(browser.contentWindow.wrappedJSObject.testVar, undefined,
63 "variable should no longer be there");
64 is(notificationCount, 2, "Should notify on second navigation");
66 browser.goBack();
67 yield;
68 is(browser.contentWindow.wrappedJSObject.testVar, 1,
69 "variable should still be there");
70 is(notificationCount, 2, "Should not notify on back navigation");
72 browser.loadURI("http://mochi.test:8888/tests/docshell/test/chrome/582176_xml.xml");
73 yield;
74 is(browser.contentDocument.body.textContent, "xslt result",
75 "Transform performed successfully");
76 is(notificationCount, 3, "Should notify only once on XSLT navigation");
78 os.removeObserver(observer, "content-document-global-created")
80 // Tell the framework the test is finished. Include the final 'yield'
81 // statement to prevent a StopIteration exception from being thrown.
82 finish();
83 yield;
86 ]]></script>
87 <browser type="content-primary" flex="1" id="content" src="about:blank"/>
88 </window>