browser_browsingContext-getWindowByName.js (818B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 function addWindow(name) { 7 var blank = Cc["@mozilla.org/supports-string;1"].createInstance( 8 Ci.nsISupportsString 9 ); 10 blank.data = "about:blank"; 11 let promise = BrowserTestUtils.waitForNewWindow({ 12 anyWindow: true, 13 url: "about:blank", 14 }); 15 Services.ww.openWindow( 16 null, 17 AppConstants.BROWSER_CHROME_URL, 18 name, 19 "chrome,dialog=no", 20 blank 21 ); 22 return promise; 23 } 24 25 add_task(async function () { 26 let windows = [await addWindow("first"), await addWindow("second")]; 27 28 for (let w of windows) { 29 isnot(w, null); 30 is(Services.ww.getWindowByName(w.name, null), w, `Found ${w.name}`); 31 } 32 33 await Promise.all(windows.map(BrowserTestUtils.closeWindow)); 34 });