https://github.com/web-platform-tests/wpt
Raw File
Tip revision: d56e1a8e1d3a6661b4c0ba56b67d48338426e3c9 authored by Ms2ger on 02 October 2018, 12:50:48 UTC
Refactor drawimage_svg_image_1.html.
Tip revision: d56e1a8
block-string-assignment-to-Window-open.tentative.html
<!DOCTYPE html>
<html>
<head>
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="support/helper.sub.js"></script>

  <meta http-equiv="Content-Security-Policy" content="trusted-types">
</head>
<body>
<script>
  var testnb = 0;
  // helper functions for the tests
  function testWindowOpen(t, win, nb) {
    let p = createURL_policy(window, nb);
    let url = p.createURL(INPUTS.URL);
    let child_window = win.open(url, "", "");
    child_window.onload = t.step_func_done(_ => {
      assert_equals(child_window.location.href, "" + url);
      child_window.close();
    });
  }

  function testWindowThrows(t, url, win, nb) {
    let p = createURL_policy(window, nb);
    assert_throws(new TypeError(), _ => {
      let child_window = win.open(url, "", "");
      child_window.close();
    });
  }

  // TrustedURL assignments do not throw.
  test(t => {
    testWindowOpen(t, window, ++testnb);
  }, "window.open via policy (successful URL transformation).");

  test(t => {
    testWindowOpen(t, document, ++testnb);
  }, "document.open via policy (successful URL transformation).");

  // String assignments throw.
  test(t => {
    testWindowThrows(t, 'A string', window, ++testnb);
  }, "`window.open(string)` throws.");

  test(t => {
    testWindowThrows(t, 'A string', document, ++testnb);
  }, "`document.open(string)` throws.");

  // Null assignment throws.
  test(t => {
    testWindowThrows(t, null, window, ++testnb);
  }, "`window.open(null)` throws.");

  test(t => {
    testWindowThrows(t, null, document, ++testnb);
  }, "`document.open(null)` throws.");
</script>
</body>
</html>
back to top