browser_524745.js (1844B)
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 524745 */ 7 8 let uniqKey = "bug524745"; 9 let uniqVal = Date.now().toString(); 10 11 waitForExplicitFinish(); 12 13 whenNewWindowLoaded({ private: false }, function (window_B) { 14 waitForFocus(function () { 15 // Add identifying information to window_B 16 ss.setCustomWindowValue(window_B, uniqKey, uniqVal); 17 let state = JSON.parse(ss.getBrowserState()); 18 let selectedWindow = state.windows[state.selectedWindow - 1]; 19 is( 20 selectedWindow.extData && selectedWindow.extData[uniqKey], 21 uniqVal, 22 "selectedWindow is window_B" 23 ); 24 25 // Now minimize window_B. The selected window shouldn't have the secret data 26 window_B.minimize(); 27 waitForFocus(async function () { 28 state = JSON.parse(ss.getBrowserState()); 29 selectedWindow = state.windows[state.selectedWindow - 1]; 30 ok( 31 !selectedWindow.extData || !selectedWindow.extData[uniqKey], 32 "selectedWindow is not window_B after minimizing it" 33 ); 34 35 // Now minimize the last open window (assumes no other tests left windows open) 36 let promiseSizeModeChange = BrowserTestUtils.waitForEvent( 37 window, 38 "sizemodechange" 39 ); 40 window.minimize(); 41 await promiseSizeModeChange; 42 state = JSON.parse(ss.getBrowserState()); 43 is( 44 state.selectedWindow, 45 0, 46 "selectedWindow should be 0 when all windows are minimized" 47 ); 48 49 // Cleanup 50 window.restore(); 51 BrowserTestUtils.closeWindow(window_B).then(finish); 52 }); 53 }, window_B); 54 }); 55 }