https://github.com/web-platform-tests/wpt
Raw File
Tip revision: e1321f59e821319d86425ee9027458ff9db35b05 authored by Jaewon Choi on 22 October 2018, 16:31:16 UTC
Add SameObject attribute to navigator xr with wpt
Tip revision: e1321f5
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