Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/ipc/tests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  test_bug1086684.js   Sprache: JAVA

 
"use strict";

const { XPCShellContentUtils } = ChromeUtils.importESModule(
  "resource://testing-common/XPCShellContentUtils.sys.mjs"
);

XPCShellContentUtils.init(this);

const childFramePath = "/file_bug1086684.html";
const childFrameURL = "http://example.com" + childFramePath;

const childFrameContents = `<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
</head>
<body>
<div id="content">
    <input type="file" id="f">
</div>
</body>
</html>`;

const server = XPCShellContentUtils.createHttpServer({
  hosts: ["example.com"],
});
server.registerPathHandler(childFramePath, (request, response) => {
  response.write(childFrameContents);
});

function childFrameScript() {
  /* eslint-env mozilla/frame-script */
  "use strict";

  let { MockFilePicker } = ChromeUtils.importESModule(
    "resource://testing-common/MockFilePicker.sys.mjs"
  );

  function parentReady(message) {
    MockFilePicker.init(content.browsingContext);
    MockFilePicker.setFiles([message.data.file]);
    MockFilePicker.returnValue = MockFilePicker.returnOK;

    let input = content.document.getElementById("f");
    input.addEventListener("change", () => {
      MockFilePicker.cleanup();
      let value = input.value;
      message.target.sendAsyncMessage("testBug1086684:childDone", { value });
    });

    // Activate the page to allow opening the file picker.
    content.document.notifyUserGestureActivation();

    input.focus();
    input.click();
  }

  addMessageListener("testBug1086684:parentReady"function (message) {
    parentReady(message);
  });
}

add_task(async function () {
  Services.prefs.setBoolPref("dom.security.https_first"false);
  let page = await XPCShellContentUtils.loadContentPage(childFrameURL, {
    remote: true,
  });

  page.loadFrameScript(childFrameScript);

  await new Promise(resolve => {
    let test;
    function* testStructure(mm) {
      let value;

      function testDone(msg) {
        test.next(msg.data.value);
      }

      mm.addMessageListener("testBug1086684:childDone", testDone);

      let blob = new Blob([]);
      let file = new File([blob], "helloworld.txt", { type: "text/plain" });

      mm.sendAsyncMessage("testBug1086684:parentReady", { file });
      value = yield;

      // Note that the "helloworld.txt" passed in above doesn't affect the
      // 'value' getter. Because we're mocking a file using a blob, we ask the
      // blob for its path, which is the empty string.
      equal(value, """got the right answer and didn't crash");

      resolve();
    }

    test = testStructure(page.browser.messageManager);
    test.next();
  });

  await page.close();
  Services.prefs.clearUserPref("dom.security.https_first");
});

Messung V0.5
C=93 H=100 G=96

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.