Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  test_bug1699721.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/docshell/test/navigation/test_bug1699721.html


<!DOCTYPE html>
<html>
<head>
    <script src="/tests/SimpleTest/SimpleTest.js"></script>
    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script type="text/javascript">
  add_task(async function() {
    // Induce a process switching behavior for example.com
    // with isolateHighValue isolation strategy
    // (because we test specifically process switching behavior here)
    await SpecialPowers.pushPermissions([
      {
        type: "highValueCOOP",
        allow: SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION,
        context: "https://example.com",
      }
    ]);

    let popup = window.open("blank.html");

    info("opened popup");
    await new Promise(resolve => {
      popup.addEventListener("load", resolve, { once: true });
    });

    info("popup blank.html loaded");
    let tell_opener = new URL("file_tell_opener.html", location.href);
    // eslint-disable-next-line @microsoft/sdl/no-insecure-url
    let xorigin_url = new URL(tell_opener.pathname, "https://example.com");

    let resolveStartedUnload;
    let startedUnload = new Promise(resolve => {
      resolveStartedUnload = resolve;
    });
    let didFinishUnload = false;

    let finishUnload = false;
    popup.addEventListener("unload", function() {
      resolveStartedUnload();
      try {
        // Spin a nested event loop in unload until we set `finishUnload`.
        SpecialPowers.Services.tm.spinEventLoopUntil(
          "Test(test_switch_back_nested.html)", () => finishUnload);
      } finally {
        info("exiting from unload nested event loop...");
        didFinishUnload = true;
      }
    });

    info("wait for message from popup");
    let messagePromise = new Promise(resolve => {
      addEventListener("message", () => {
        resolve();
      }, { once: true });
    });
    popup.location = xorigin_url.href;
    await messagePromise;

    info("popup loaded, ensuring we're in unload");
    await startedUnload;
    is(didFinishUnload, false, "unload shouldn't have finished");

    let switchStarted = SpecialPowers.spawnChrome([], async () => {
      await new Promise(resolve => {
        async function observer(subject, topic) {
          is(topic, "http-on-examine-response");

          let uri = subject.QueryInterface(Ci.nsIChannel).URI;
          if (!uri.filePath.endsWith("file_tell_opener.html")) {
            return;
          }

          Services.obs.removeObserver(observer, "http-on-examine-response");

          // spin the event loop a few times to ensure we resolve after the process switch
          for (let i = 0; i < 10; ++i) {
            await new Promise(res => Services.tm.dispatchToMainThread(res));
          }

          info("resolving!");
          resolve();
        }
        Services.obs.addObserver(observer, "http-on-examine-response");
      });
    });

    info("Navigating back to the current process");
    await SpecialPowers.spawn(popup, [tell_opener.href], (href) => {
      content.location.href = href;
    });

    let messagePromise2 = new Promise(resolve => {
      addEventListener("message", () => {
        resolve();
      }, { once: true });
    });

    info("Waiting for the process switch to start");
    await switchStarted;

    // Finish unloading, and wait for the unload to complete
    is(didFinishUnload, false, "unload shouldn't be finished");
    finishUnload = true;
    await new Promise(resolve => setTimeout(resolve, 0));
    is(didFinishUnload, true, "unload should be finished");

    info("waiting for navigation to complete");
    await messagePromise2;

    info("closing popup");
    popup.close();

    ok(true, "Didn't crash");
  });
</script>
</pre>
</body>
</html>

100%


¤ Dauer der Verarbeitung: 0.23 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 ist noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge