browser_463206.js (2807B)
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 "use strict"; 6 7 const MOCHI_ROOT = ROOT.replace( 8 "chrome://mochitests/content/", 9 "http://mochi.test:8888/" 10 ); 11 if (gFissionBrowser) { 12 addCoopTask( 13 "browser_463206_sample.html", 14 test_restore_text_data_subframes, 15 HTTPSROOT 16 ); 17 } 18 addNonCoopTask( 19 "browser_463206_sample.html", 20 test_restore_text_data_subframes, 21 HTTPSROOT 22 ); 23 addNonCoopTask( 24 "browser_463206_sample.html", 25 test_restore_text_data_subframes, 26 HTTPROOT 27 ); 28 addNonCoopTask( 29 "browser_463206_sample.html", 30 test_restore_text_data_subframes, 31 MOCHI_ROOT 32 ); 33 34 async function test_restore_text_data_subframes(aURL) { 35 // Add a new tab. 36 let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, aURL); 37 38 await setPropertyOfFormField( 39 tab.linkedBrowser, 40 "#out1", 41 "value", 42 Date.now().toString(16) 43 ); 44 45 await setPropertyOfFormField( 46 tab.linkedBrowser, 47 "input[name='1|#out2']", 48 "value", 49 Math.random() 50 ); 51 52 await setPropertyOfFormField( 53 tab.linkedBrowser.browsingContext.children[0].children[1], 54 "#in1", 55 "value", 56 new Date() 57 ); 58 59 // Duplicate the tab. 60 let tab2 = gBrowser.duplicateTab(tab); 61 let browser2 = tab2.linkedBrowser; 62 await promiseTabRestored(tab2); 63 64 isnot( 65 await getPropertyOfFormField(browser2, "#out1", "value"), 66 await getPropertyOfFormField( 67 browser2.browsingContext.children[1], 68 "#out1", 69 "value" 70 ), 71 "text isn't reused for frames" 72 ); 73 74 isnot( 75 await getPropertyOfFormField(browser2, "input[name='1|#out2']", "value"), 76 "", 77 "text containing | and # is correctly restored" 78 ); 79 80 is( 81 await getPropertyOfFormField( 82 browser2.browsingContext.children[1], 83 "#out2", 84 "value" 85 ), 86 "", 87 "id prefixes can't be faked" 88 ); 89 90 // Query a few values from the top and its child frames. 91 await SpecialPowers.spawn(tab2.linkedBrowser, [], async function () { 92 // Bug 588077 93 // XXX(farre): disabling this, because it started passing more heavily on Windows. 94 /* 95 let in1ValFrame0_1 = await SpecialPowers.spawn( 96 content.frames[0], 97 [], 98 async function() { 99 return SpecialPowers.spawn(content.frames[1], [], async function() { 100 return content.document.getElementById("in1").value; 101 }); 102 } 103 ); 104 todo_is(in1ValFrame0_1, "", "id prefixes aren't mixed up"); 105 */ 106 }); 107 108 is( 109 await getPropertyOfFormField( 110 browser2.browsingContext.children[1].children[0], 111 "#in1", 112 "value" 113 ), 114 "", 115 "id prefixes aren't mixed up" 116 ); 117 // Cleanup. 118 gBrowser.removeTab(tab2); 119 gBrowser.removeTab(tab); 120 }