tor-browser

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

compile-event-handler-settings-objects.html (2479B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Entry and incumbent settings objects when compiling an inline event handler</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 
      7 <div id="log"></div>
      8 
      9 <script>
     10 "use strict";
     11 window.name = "parent frame";
     12 
     13 async_test(t => {
     14  const iframe = document.createElement("iframe");
     15  iframe.src = "resources/compiled-event-handler-settings-objects-support.html";
     16  iframe.onload = t.step_func(() => {
     17    const button = iframe.contentDocument.querySelector("button");
     18    const compiled = button.onclick;
     19 
     20    assert_equals(compiled.constructor, iframe.contentWindow.Function, "The constructor must be from the iframe");
     21    assert_not_equals(compiled.constructor, Function, "The constructor must not be from this page");
     22 
     23    t.done();
     24  });
     25 
     26  document.body.appendChild(iframe);
     27 
     28 }, "The Function instance must be created in the Realm of the node document");
     29 
     30 async_test(t => {
     31  const iframe = document.createElement("iframe");
     32  iframe.src = "resources/compiled-event-handler-settings-objects-support.html";
     33  iframe.onload = t.step_func(() => {
     34    const button = iframe.contentDocument.querySelector("button");
     35 
     36    window.onWindowLoaded = t.step_func_done(url => {
     37      const pathname = new URL(url).pathname;
     38      assert_equals(pathname,
     39        "/html/webappapis/scripting/events/resources/open-window.html");
     40      // This tests that the entry settings object used to resolve URLs in that window.open() was the same as that
     41      // of the node document (i.e. the iframe document), not e.g. this window.
     42    });
     43 
     44    button.click();
     45  });
     46 
     47  document.body.appendChild(iframe);
     48 
     49 }, "The entry settings object while executing the compiled callback via Web IDL's invoke must be that " +
     50   "of the node document");
     51 
     52 async_test(t => {
     53  const iframe = document.createElement("iframe");
     54  iframe.src = "resources/compiled-event-handler-settings-objects-support.html";
     55  iframe.onload = t.step_func(() => {
     56    window.onmessage = t.step_func_done(event => {
     57      assert_equals(event.data, "PASS");
     58      assert_equals(event.source.name, "iframe");
     59      assert_equals(event.source, iframe.contentWindow, "The source must be the iframe");
     60    });
     61 
     62    iframe.src = "about:blank";
     63  });
     64 
     65  document.body.appendChild(iframe);
     66 
     67 }, "The incumbent settings object while executing the compiled callback via Web IDL's invoke must be that " +
     68   "of the node document");
     69 </script>