summaryrefslogtreecommitdiffstats
path: root/gfx/tests/browser/browser_windowless_troubleshoot_crash.js
blob: 44fc50e2f8f76c13092a0e1c8b3f142bb3d8b9f4 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
add_task(async function test_windowlessBrowserTroubleshootCrash() {
  let webNav = Services.appShell.createWindowlessBrowser(false);

  let onLoaded = new Promise((resolve, reject) => {
    let docShell = webNav.docShell;
    let listener = {
      observe(contentWindow, topic, data) {
        let observedDocShell =
          contentWindow.docShell.sameTypeRootTreeItem.QueryInterface(
            Ci.nsIDocShell
          );
        if (docShell === observedDocShell) {
          Services.obs.removeObserver(
            listener,
            "content-document-global-created"
          );
          resolve();
        }
      },
    };
    Services.obs.addObserver(listener, "content-document-global-created");
  });
  let loadURIOptions = {
    triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
  };
  webNav.loadURI(Services.io.newURI("about:blank"), loadURIOptions);

  await onLoaded;

  let winUtils = webNav.document.defaultView.windowUtils;
  try {
    let layerManager = winUtils.layerManagerType;
    ok(
      layerManager == "Basic" || layerManager == "WebRender (Software)",
      "windowless browser's layerManagerType should be 'Basic' or 'WebRender (Software)'"
    );
  } catch (e) {
    // The windowless browser may not have a layermanager at all yet, and that's ok.
    // The troubleshooting code similarly skips over windows with no layer managers.
  }
  ok(true, "not crashed");

  var { Troubleshoot } = ChromeUtils.importESModule(
    "resource://gre/modules/Troubleshoot.sys.mjs"
  );
  var data = await Troubleshoot.snapshot();

  ok(
    data.graphics.windowLayerManagerType !== "None",
    "windowless browser window should not set windowLayerManagerType to 'None'"
  );

  webNav.close();
});