Commit 2ec3fdc3 authored by Luca Greco's avatar Luca Greco
Browse files

Bug 1746869 - Change test_ext_userScripts.js test_scriptMetaData to use a...

Bug 1746869 - Change test_ext_userScripts.js test_scriptMetaData to use a separate content page to test the userScript API script. r=robwu

By bisecting which one of the test cases defined in test_ext_userScripts.js was triggering this issue, test_scriptMetaData, I did notice
that this is the only test case in this test file to be using an iframe to create the webcontent page to test the api script on.

Using a separate content page does not trigger the issue and the xpcshell-test process does exist as expected in both
in-process and remote webextensions mode.

It may be reasonable to also separately make sure that recreating the same scenario in a real browser instance (e.g. GeckoView)
does not trigger the same kind of issue.

Differential Revision: https://phabricator.services.mozilla.com/D134289
parent 8032ae5c
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -573,20 +573,16 @@ add_task(async function test_scriptMetaData() {
    ];
  }

  async function background(pageUrl) {
  async function background() {
    for (let scriptMetadata of getTestCases(true)) {
      await browser.userScripts.register({
        js: [{ file: "userscript.js" }],
        runAt: "document_end",
        allFrames: true,
        matches: ["http://localhost/*/file_sample.html"],
        scriptMetadata,
      });
    }

    let f = document.createElement("iframe");
    f.src = pageUrl;
    document.body.append(f);
    browser.test.sendMessage("background-page:done");
  }

@@ -620,7 +616,7 @@ add_task(async function test_scriptMetaData() {
  }

  let extension = ExtensionTestUtils.loadExtension({
    background: `${getTestCases};(${background})("${BASE_URL}/file_sample.html")`,
    background: `${getTestCases};(${background})()`,
    manifest: {
      permissions: ["http://*/*/file_sample.html"],
      user_scripts: {
@@ -636,8 +632,15 @@ add_task(async function test_scriptMetaData() {
  await extension.startup();

  await extension.awaitMessage("background-page:done");

  const pageUrl = `${BASE_URL}/file_sample.html`;
  info(`Load content page: ${pageUrl}`);
  const page = await ExtensionTestUtils.loadContentPage(pageUrl);

  await extension.awaitMessage("apiscript:done");

  await page.close();

  await extension.unload();
});