browser_477657.js (2156B)
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 add_task(async function test_sizemodeDefaults() { 6 /** Test for Bug 477657 */ 7 let newWin = openDialog(location, "_blank", "chrome,all,dialog=no"); 8 await promiseWindowLoaded(newWin); 9 let newState = { 10 windows: [ 11 { 12 tabs: [{ entries: [] }], 13 _closedTabs: [ 14 { 15 state: { entries: [{ url: "about:" }] }, 16 title: "About:", 17 }, 18 ], 19 sizemode: "maximized", 20 }, 21 ], 22 }; 23 24 let uniqueKey = "bug 477657"; 25 let uniqueValue = "unik" + Date.now(); 26 27 ss.setCustomWindowValue(newWin, uniqueKey, uniqueValue); 28 is( 29 ss.getCustomWindowValue(newWin, uniqueKey), 30 uniqueValue, 31 "window value was set before the window was overwritten" 32 ); 33 34 await setWindowState(newWin, newState, true); 35 // use newWin.setTimeout(..., 0) to mirror sss_restoreWindowFeatures 36 await new Promise(resolve => newWin.setTimeout(resolve, 0)); 37 38 is( 39 ss.getCustomWindowValue(newWin, uniqueKey), 40 "", 41 "window value was implicitly cleared" 42 ); 43 44 is(newWin.windowState, newWin.STATE_MAXIMIZED, "the window was maximized"); 45 46 is( 47 ss.getClosedTabDataForWindow(newWin).length, 48 1, 49 "the closed tab was added before the window was overwritten" 50 ); 51 delete newState.windows[0]._closedTabs; 52 delete newState.windows[0].sizemode; 53 54 await setWindowState(newWin, newState, true); 55 await new Promise(resolve => newWin.setTimeout(resolve, 0)); 56 57 is( 58 ss.getClosedTabDataForWindow(newWin).length, 59 0, 60 "closed tabs were implicitly cleared" 61 ); 62 63 is( 64 newWin.windowState, 65 newWin.STATE_MAXIMIZED, 66 "the window remains maximized" 67 ); 68 newState.windows[0].sizemode = "normal"; 69 70 await setWindowState(newWin, newState, true); 71 await new Promise(resolve => newWin.setTimeout(resolve, 0)); 72 73 isnot( 74 newWin.windowState, 75 newWin.STATE_MAXIMIZED, 76 "the window was explicitly unmaximized" 77 ); 78 79 await BrowserTestUtils.closeWindow(newWin); 80 });