tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

navigate-to-srcdoc.html (1387B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <iframe id="iframe" name="i" src="/common/blank.html"></iframe>
      5 
      6 <script>
      7 async_test(t => {
      8  window.onload = t.step_func(() => {
      9    navigation.onnavigate = t.unreached_func("onnavigate should not have fired in source window");
     10 
     11    iframe.contentWindow.navigation.onnavigate = t.step_func(e => {
     12      assert_equals(e.navigationType, "push");
     13      assert_true(e.cancelable, "cancelable");
     14      assert_false(e.canIntercept, "canIntercept");
     15      assert_false(e.userInitiated, "userInitiated");
     16      assert_false(e.hashChange, "hashChange");
     17      assert_equals(e.downloadRequest, null);
     18      assert_equals(e.destination.url, "about:srcdoc");
     19      assert_false(e.destination.sameDocument);
     20      assert_equals(e.destination.key, "");
     21      assert_equals(e.destination.id, "");
     22      assert_equals(e.destination.index, -1);
     23      assert_equals(e.formData, null);
     24      assert_equals(e.sourceElement, null);
     25      e.preventDefault();
     26 
     27      // Make sure it doesn't navigate anyway.
     28      iframe.onload = t.unreached_func("Must not load the srcdoc document");
     29      t.step_timeout(() => t.done(), 10);
     30    });
     31 
     32    iframe.srcdoc = "srcdoc contents";
     33  });
     34 }, "navigate event fires appropriately (and can be canceled) for adding the srcdoc attribute");
     35 </script>