Bug 1620591 [wpt PR 22118] - Make Trusted Types ununforgeable., a=testonly
authorMike West <mkwst@chromium.org>
Mon, 09 Mar 2020 21:45:05 +0000
changeset 518182 643c88e00d7f34490218c623cad4d1ecec9fe30d
parent 518181 0c2493cb15276e82db0db0b7de810304b2b2e61e
child 518183 0dd71569eb6488daa7782698a8431a82f1580e68
push id109810
push userwptsync@mozilla.com
push dateWed, 11 Mar 2020 14:32:53 +0000
treeherderautoland@7a1bf4c17b25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1620591, 22118, 1058400, 2089705, 748022
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1620591 [wpt PR 22118] - Make Trusted Types ununforgeable., a=testonly Automatic update from web-platform-tests Make Trusted Types ununforgeable. Context: https://github.com/w3c/webappsec-trusted-types/issues/257 Bug: 1058400 Change-Id: Ie91e8ad7e8eff814e3aaa1d940ca0bc1d6c2f09e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089705 Reviewed-by: Yifan Luo <lyf@chromium.org> Commit-Queue: Mike West <mkwst@chromium.org> Cr-Commit-Position: refs/heads/master@{#748022} -- wpt-commits: 7c966db714c251c2b7bc243b9657e5dff72aa8dc wpt-pr: 22118
testing/web-platform/tests/interfaces/trusted-types.tentative.idl
testing/web-platform/tests/trusted-types/TrustedTypePolicyFactory-isXXX.tentative.html
--- a/testing/web-platform/tests/interfaces/trusted-types.tentative.idl
+++ b/testing/web-platform/tests/interfaces/trusted-types.tentative.idl
@@ -1,41 +1,51 @@
 // https://github.com/wicg/trusted-types
 
 typedef (DOMString or TrustedHTML) HTMLString;
 typedef (DOMString or TrustedScript) ScriptString;
 typedef (DOMString or TrustedScriptURL) ScriptURLString;
 
-[Exposed=(Window, Worker)]
-interface TrustedHTML {
+[
+  Exposed=(Window, Worker),
+  SecureContext
+] interface TrustedHTML {
     stringifier;
 };
 
-[Exposed=(Window, Worker)]
-interface TrustedScript {
+[
+  Exposed=(Window, Worker),
+  SecureContext
+] interface TrustedScript {
     stringifier;
 };
 
-[Exposed=(Window, Worker)]
-interface TrustedScriptURL {
+[
+  Exposed=(Window, Worker),
+  SecureContext
+] interface TrustedScriptURL {
     stringifier;
 };
 
-[Exposed=(Window, Worker)]
-interface TrustedTypePolicyFactory {
-    [Unforgeable] TrustedTypePolicy createPolicy(DOMString policyName, TrustedTypePolicyOptions policyOptions);
+[
+  Exposed=(Window, Worker),
+  SecureContext
+] interface TrustedTypePolicyFactory {
+    TrustedTypePolicy createPolicy(DOMString policyName, TrustedTypePolicyOptions policyOptions);
     // All the policy object names that have been created
 };
 
-[Exposed=(Window, Worker)]
-interface TrustedTypePolicy {
-    [Unforgeable] readonly attribute DOMString name;
-    [Unforgeable] TrustedHTML createHTML(DOMString input);
-    [Unforgeable] TrustedScript createScript(DOMString input);
-    [Unforgeable] TrustedScriptURL createScriptURL(DOMString input);
+[
+  Exposed=(Window, Worker),
+  SecureContext
+] interface TrustedTypePolicy {
+    readonly attribute DOMString name;
+    TrustedHTML createHTML(DOMString input);
+    TrustedScript createScript(DOMString input);
+    TrustedScriptURL createScriptURL(DOMString input);
 };
 
 dictionary TrustedTypePolicyOptions {
    CreateHTMLCallback createHTML;
    CreateScriptCallback createScript;
    CreateURLCallback createScriptURL;
 };
 
--- a/testing/web-platform/tests/trusted-types/TrustedTypePolicyFactory-isXXX.tentative.html
+++ b/testing/web-platform/tests/trusted-types/TrustedTypePolicyFactory-isXXX.tentative.html
@@ -77,45 +77,9 @@
     assert_false(trustedTypes.isScript('test'));
     assert_false(trustedTypes.isScript({}));
     assert_false(trustedTypes.isScriptURL(null));
     assert_false(trustedTypes.isScriptURL(123));
     assert_false(trustedTypes.isScriptURL(0.5));
     assert_false(trustedTypes.isScriptURL('test'));
     assert_false(trustedTypes.isScriptURL({}));
   }, 'TrustedTypePolicyFactory.isXXX should accept anything without throwing.');
-
-  // Redefinition tests, assign to property.
-  // (Assignments will through in the polyfill (because the objects are frozen)
-  //  but will be silently dropped in the native implementation (because that's
-  //  what [Unforgeable] does. Hence, the tests use try {..} catch {} to cover
-  //  both situationsm rather than expect_throws(...).)
-  test(t => {
-    try { trustedTypes.isHTML = () => 'fake'; } catch { }
-    assert_false(trustedTypes.isHTML({}));
-  }, 'TrustedTypePolicyFactory.IsHTML cannot be redefined.');
-
-  test(t => {
-    try { trustedTypes.isScript = () => 'fake'; } catch { }
-    assert_false(trustedTypes.isScript({}));
-  }, 'TrustedTypePolicyFactory.isScript cannot be redefined.');
-
-  test(t => {
-    try { trustedTypes.isScriptURL = () => 'fake'; } catch { }
-    assert_false(trustedTypes.isScriptURL({}));
-  }, 'TrustedTypePolicyFactory.isScriptURL cannot be redefined.');
-
-  // Redefinition tests, via Object.defineProperty.
-  test(t => {
-    try { Object.defineProperty(trustedTypes, 'isHTML', () => 'fake'); } catch { }
-    assert_false(trustedTypes.isHTML({}));
-  }, 'TrustedTypePolicyFactory.IsHTML cannot be redefined via defineProperty.');
-
-  test(t => {
-    try { Object.defineProperty(trustedTypes, 'isScript', () => 'fake'); } catch { }
-    assert_false(trustedTypes.isScript({}));
-  }, 'TrustedTypePolicyFactory.isScript cannot be redefined via definePropert.');
-
-  test(t => {
-    try { Object.defineProperty(trustedTypes, 'isScriptURL', () => 'fake'); } catch { }
-    assert_false(trustedTypes.isScriptURL({}));
-  }, 'TrustedTypePolicyFactory.isScriptURL cannot be redefined via definePropert.');
 </script>