summaryrefslogtreecommitdiffstats
path: root/docshell/test/browser/browser_browsingContext-getWindowByName.js
blob: e57691b2703395549a35738a0192f6e6ca4cfff0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

function addWindow(name) {
  var blank = Cc["@mozilla.org/supports-string;1"].createInstance(
    Ci.nsISupportsString
  );
  blank.data = "about:blank";
  let promise = BrowserTestUtils.waitForNewWindow({
    anyWindow: true,
    url: "about:blank",
  });
  Services.ww.openWindow(
    null,
    AppConstants.BROWSER_CHROME_URL,
    name,
    "chrome,dialog=no",
    blank
  );
  return promise;
}

add_task(async function () {
  let windows = [await addWindow("first"), await addWindow("second")];

  for (let w of windows) {
    isnot(w, null);
    is(Services.ww.getWindowByName(w.name, null), w, `Found ${w.name}`);
  }

  await Promise.all(windows.map(BrowserTestUtils.closeWindow));
});