testing/web-platform/tests/trusted-types/Element-setAttribute.tentative.html
author Razvan Maries <rmaries@mozilla.com>
Thu, 26 Nov 2020 07:56:23 +0200
changeset 558457 7184fb5a42fbdd37b1d4863045bea812223ffd41
parent 531924 e07cf3d4936f99965d8d52afab0560b7cbfd7975
permissions -rw-r--r--
Backed out changeset 646459eb4a35 (bug 1459118) as per Henrik's request. CLOSED TREE

<!DOCTYPE html>
<head>
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="support/helper.sub.js"></script>
</head>
<body>
<script>
  // TrustedScriptURL Assignments
  let scriptTestCases = [
    [ 'embed', 'src' ],
    [ 'script', 'src' ]
  ];

  scriptTestCases.forEach(c => {
    test(t => {
      assert_element_accepts_trusted_script_url_explicit_set(window, c, t, c[0], c[1], RESULTS.SCRIPTURL);
    }, c[0] + "." + c[1] + " assigned via policy (successful ScriptURL transformation)");
  });

  // TrustedHTML Assignments
  let HTMLTestCases = [
    [ 'iframe', 'srcdoc' ]
  ];

  HTMLTestCases.forEach(c => {
    test(t => {
      assert_element_accepts_trusted_html_explicit_set(window, c, t, c[0], c[1], RESULTS.HTML);
    }, c[0] + "." + c[1] + " assigned via policy (successful HTML transformation)");
  });

  // Other attributes can be assigned with TrustedTypes or strings or null values
  test(t => {
    assert_element_accepts_trusted_script_url_explicit_set(window, 'scriptsrc1', t, 'script', 'src', RESULTS.SCRIPTURL);
  }, "script.src assigned via policy (successful script transformation)");

  test(t => {
    assert_element_accepts_non_trusted_type_explicit_set('a', 'rel', 'A string', 'A string');
  }, "a.rel accepts strings");

  test(t => {
    assert_element_accepts_non_trusted_type_explicit_set('a', 'rel', null, 'null');
  }, "a.rel accepts null");
</script>