|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 function test() { |
|
6 /** Test for Bug 463206 **/ |
|
7 |
|
8 waitForExplicitFinish(); |
|
9 |
|
10 let testURL = "http://mochi.test:8888/browser/" + |
|
11 "browser/components/sessionstore/test/browser_463206_sample.html"; |
|
12 |
|
13 var frameCount = 0; |
|
14 let tab = gBrowser.addTab(testURL); |
|
15 tab.linkedBrowser.addEventListener("load", function(aEvent) { |
|
16 // wait for all frames to load completely |
|
17 if (frameCount++ < 5) |
|
18 return; |
|
19 tab.linkedBrowser.removeEventListener("load", arguments.callee, true); |
|
20 |
|
21 function typeText(aTextField, aValue) { |
|
22 aTextField.value = aValue; |
|
23 |
|
24 let event = aTextField.ownerDocument.createEvent("UIEvents"); |
|
25 event.initUIEvent("input", true, true, aTextField.ownerDocument.defaultView, 0); |
|
26 aTextField.dispatchEvent(event); |
|
27 } |
|
28 |
|
29 let doc = tab.linkedBrowser.contentDocument; |
|
30 typeText(doc.getElementById("out1"), Date.now()); |
|
31 typeText(doc.getElementsByName("1|#out2")[0], Math.random()); |
|
32 typeText(doc.defaultView.frames[0].frames[1].document.getElementById("in1"), new Date()); |
|
33 |
|
34 let tab2 = gBrowser.duplicateTab(tab); |
|
35 whenTabRestored(tab2, function() { |
|
36 let doc = tab2.linkedBrowser.contentDocument; |
|
37 let win = tab2.linkedBrowser.contentWindow; |
|
38 isnot(doc.getElementById("out1").value, |
|
39 win.frames[1].document.getElementById("out1").value, |
|
40 "text isn't reused for frames"); |
|
41 isnot(doc.getElementsByName("1|#out2")[0].value, "", |
|
42 "text containing | and # is correctly restored"); |
|
43 is(win.frames[1].document.getElementById("out2").value, "", |
|
44 "id prefixes can't be faked"); |
|
45 // Disabled for now, Bug 588077 |
|
46 // isnot(win.frames[0].frames[1].document.getElementById("in1").value, "", |
|
47 // "id prefixes aren't mixed up"); |
|
48 is(win.frames[1].frames[0].document.getElementById("in1").value, "", |
|
49 "id prefixes aren't mixed up"); |
|
50 |
|
51 // clean up |
|
52 gBrowser.removeTab(tab2); |
|
53 gBrowser.removeTab(tab); |
|
54 |
|
55 finish(); |
|
56 }); |
|
57 }, true); |
|
58 } |