|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <window title="Mozilla Bug 449780" onload="doTheTest()" |
|
4 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
5 |
|
6 <hbox id="parent"> |
|
7 </hbox> |
|
8 |
|
9 <!-- test code goes here --> |
|
10 <script type="application/javascript"><![CDATA[ |
|
11 var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ]; |
|
12 for each (var name in imports) { |
|
13 window[name] = window.opener.wrappedJSObject[name]; |
|
14 } |
|
15 |
|
16 function $(id) { |
|
17 return document.getElementById(id); |
|
18 } |
|
19 |
|
20 function addBrowser(parent, id, width, height) { |
|
21 var b = |
|
22 document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "browser"); |
|
23 b.setAttribute("type", "content"); |
|
24 b.setAttribute("id", id); |
|
25 b.setAttribute("width", width); |
|
26 b.setAttribute("height", height); |
|
27 $(parent).appendChild(b); |
|
28 } |
|
29 addBrowser("parent", "f1", 300, 200); |
|
30 addBrowser("parent", "f2", 300, 200); |
|
31 |
|
32 /** Test for Bug 449780 **/ |
|
33 var doc1 = "data:text/html,<html><body>This is a test</body></html>"; |
|
34 var doc2 = "data:text/html,<html><body>This is a second test</body></html>"; |
|
35 |
|
36 function getDOM(id) { |
|
37 return $(id).contentDocument.documentElement.innerHTML; |
|
38 } |
|
39 |
|
40 var tester = (function() { |
|
41 var origDOM = getDOM("f1"); |
|
42 $("f1").contentDocument.body.textContent = "Modified"; |
|
43 var modifiedDOM = getDOM("f1"); |
|
44 isnot(origDOM, modifiedDOM, "DOM should be different"); |
|
45 $("f1").contentWindow.location.href = doc2; |
|
46 yield undefined; |
|
47 |
|
48 $("f1").goBack(); |
|
49 yield undefined; |
|
50 |
|
51 is(getDOM("f1"), modifiedDOM, "Should have been bfcached"); |
|
52 $("f1").goForward(); |
|
53 yield undefined; |
|
54 |
|
55 // Ignore the notifications during swap |
|
56 $("f1").removeEventListener("pageshow", testDriver, false); |
|
57 $("f1").swapDocShells($("f2")); |
|
58 $("f2").addEventListener("pageshow", testDriver, false); |
|
59 $("f2").goBack(); |
|
60 yield undefined; |
|
61 |
|
62 is(getDOM("f2"), origDOM, "Should have not have been bfcached"); |
|
63 window.close(); |
|
64 SimpleTest.finish(); |
|
65 yield undefined; |
|
66 })(); |
|
67 |
|
68 function testDriver() { |
|
69 setTimeout(function() { tester.next() }, 0); |
|
70 } |
|
71 |
|
72 function doTheTest() { |
|
73 $("f1").addEventListener("pageshow", testDriver, false); |
|
74 $("f1").setAttribute("src", doc1); |
|
75 } |
|
76 ]]></script> |
|
77 </window> |