Bug 1513974 [wpt PR 14503] - Trusted Types: Store TrustedURL and TrustedScriptURL contents as string, a=testonly
authorJakub Vrana <jakubvrana@google.com>
Thu, 31 Jan 2019 15:44:48 +0000
changeset 457879 e2fe0e1434525ad3973b9b513fda3453fb9695d1
parent 457878 9da5b97904139f7f83d061a6e2de0c83a62a0060
child 457880 a51145a90ee003d2c8e92b383874a95ffe1cba6d
push id35518
push useropoprus@mozilla.com
push dateFri, 08 Feb 2019 09:55:14 +0000
treeherdermozilla-central@3a3e393396f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1513974, 14503, 739170, 913180, 1375714, 620299
milestone67.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 1513974 [wpt PR 14503] - Trusted Types: Store TrustedURL and TrustedScriptURL contents as string, a=testonly Automatic update from web-platform-tests Trusted Types: Store TrustedURL and TrustedScriptURL contents as string Bug: 739170, 913180 Change-Id: I01391891d89aeb55e387059ed4c4a4b92c6dcd7b Reviewed-on: https://chromium-review.googlesource.com/c/1375714 Reviewed-by: Daniel Vogelheim <vogelheim@chromium.org> Reviewed-by: Mike West <mkwst@chromium.org> Commit-Queue: Daniel Vogelheim <vogelheim@chromium.org> Cr-Commit-Position: refs/heads/master@{#620299} -- wpt-commits: 1633e46ce38d4bbf708210ecfd3da72a7480ddfa wpt-pr: 14503
testing/web-platform/tests/trusted-types/TrustedTypePolicy-createXXX.tentative.html
testing/web-platform/tests/trusted-types/TrustedTypePolicyFactory-createPolicy-createXYZTests.tentative.html
testing/web-platform/tests/trusted-types/block-string-assignment-to-Element-setAttribute.tentative.html
testing/web-platform/tests/trusted-types/block-string-assignment-to-HTMLElement-generic.tentative.html
--- a/testing/web-platform/tests/trusted-types/TrustedTypePolicy-createXXX.tentative.html
+++ b/testing/web-platform/tests/trusted-types/TrustedTypePolicy-createXXX.tentative.html
@@ -31,17 +31,17 @@
     };
     policy = TrustedTypes.createPolicy(Math.random(), noopPolicy, true);
     let el = document.createElement("div");
 
     el.title = policy.createHTML(INPUTS.URL);
     assert_equals(el.title, INPUTS.URL);
 
     el.title = policy.createURL(INPUTS.HTML);
-    assert_equals(el.title, "");
+    assert_equals(el.title, INPUTS.HTML);
   }, "Attributes without type constraints will work as before.");
 
   test(t => {
     const policy = TrustedTypes.createPolicy("nullpolicy", null);
     assert_throws(new TypeError(), _ => { policy.createScriptURL("foo"); });
     assert_throws(new TypeError(), _ => { policy.createURL("foo"); });
     assert_throws(new TypeError(), _ => { policy.createHTML("foo"); });
     assert_throws(new TypeError(), _ => { policy.createScript("foo"); });
@@ -66,24 +66,24 @@
     [ s => { aGlobalVarForSideEffectTesting = s; return s }, "whatever" ],
     [ s => aGlobalVarForSideEffectTesting + s, "whateverwhatever" ],
     [ aGlobalFunction.bind(aGlobalObject), "well, whatever" ],
     [ s => aGlobalFunction(s), "a global var named foo whatever" ],
   ];
 
   const urlTestCases = [
     [ s => s, INPUTS.SCRIPTURL ],
-    [ s => null, "" ],
+    [ s => null, "null" ],
     [ s => s + "#duck", INPUTS.SCRIPTURL + "#duck" ],
     [ s => { throw new Error() }, new Error() ],
     [ s => s + "#" + aGlobalVarForSideEffectTesting,
       INPUTS.SCRIPTURL + "#global" ],
     [ anotherGlobalFunction.bind(aGlobalObject), INPUTS.SCRIPTURL + "#well," ],
     [ s => anotherGlobalFunction(s),
-      INPUTS.SCRIPTURL + "#a%20global%20var%20named%20foo" ],
+      INPUTS.SCRIPTURL + "#a global var named foo" ],
   ];
 
   function policyBuilder(trustedMethodName, trustedType, defaultArg) {
     return function(name, fn) {
       let options = {};
       options[trustedMethodName] = fn;
       let policy = window.TrustedTypes.createPolicy(name, options);
       let result = policy[trustedMethodName](defaultArg);
--- a/testing/web-platform/tests/trusted-types/TrustedTypePolicyFactory-createPolicy-createXYZTests.tentative.html
+++ b/testing/web-platform/tests/trusted-types/TrustedTypePolicyFactory-createPolicy-createXYZTests.tentative.html
@@ -160,17 +160,17 @@
     assert_equals(scriptUrl + "", expectedScriptURL);
   }
 
   test(t => {
     createScriptURLTest('TestPolicyScriptURL1', { createScriptURL: s => s }, INPUTS.SCRIPTURL, t);
   }, "script_url = identity function");
 
   test(t => {
-    createScriptURLTest('TestPolicyScriptURL2', { createScriptURL: s => null }, "", t);
+    createScriptURLTest('TestPolicyScriptURL2', { createScriptURL: s => null }, "null", t);
   }, "script_url = null");
 
   var scriptURLstr = '#duck';
   test(t => {
     createScriptURLTest('TestPolicyScriptURL3', { createScriptURL: s => s + scriptURLstr }, INPUTS.SCRIPTURL + scriptURLstr, t);
   }, "script_url = string + global string");
 
   var scriptURLx = 'global';
@@ -235,17 +235,17 @@
     assert_equals(url + "", expectedURL);
   }
 
   test(t => {
     createURLTest('TestPolicyURL1', { createURL: s => s }, INPUTS.URL, t);
   }, "url = identity function");
 
   test(t => {
-    createURLTest('TestPolicyURL2', { createURL: s => null }, "", t);
+    createURLTest('TestPolicyURL2', { createURL: s => null }, "null", t);
   }, "url = null");
 
   var URLstr = '#x';
   test(t => {
     createURLTest('TestPolicyURL3', { createURL: s => s + URLstr }, INPUTS.URL + URLstr, t);
   }, "url = string + global string");
 
   var URLx = 'global';
--- a/testing/web-platform/tests/trusted-types/block-string-assignment-to-Element-setAttribute.tentative.html
+++ b/testing/web-platform/tests/trusted-types/block-string-assignment-to-Element-setAttribute.tentative.html
@@ -61,30 +61,24 @@
     }, c[0] + "." + c[1] + " accepts only TrustedHTML");
   });
 
   // After default policy creation string and null assignments implicitly call createXYZ
   let p = window.TrustedTypes.createPolicy("default", { createURL: createURLJS, createScriptURL: createScriptURLJS, createHTML: createHTMLJS }, true);
   URLTestCases.forEach(c => {
     test(t => {
       assert_element_accepts_trusted_type(c[0], c[1], INPUTS.URL, RESULTS.URL);
-
-      // Properties that actually parse the URLs will resort to the base URL
-      // when given a null or empty URL.
-      assert_element_accepts_trusted_type(c[0], c[1], null, "" + window.location);
+      assert_element_accepts_trusted_type(c[0], c[1], null, window.location.toString().replace(/[^\/]*$/, "null"));
     }, c[0] + "." + c[1] + " accepts string and null after default policy was created.");
   });
 
   scriptURLTestCases.forEach(c => {
     test(t => {
       assert_element_accepts_trusted_type(c[0], c[1], INPUTS.SCRIPTURL, RESULTS.SCRIPTURL);
-
-      // Properties that actually parse the URLs will resort to the base URL
-      // when given a null or empty URL.
-      assert_element_accepts_trusted_type(c[0], c[1], null, "" + window.location);
+      assert_element_accepts_trusted_type(c[0], c[1], null, window.location.toString().replace(/[^\/]*$/, "null"));
     }, c[0] + "." + c[1] + " accepts string and null after default policy was created.");
   });
 
   HTMLTestCases.forEach(c => {
     test(t => {
       assert_element_accepts_trusted_type(c[0], c[1], INPUTS.HTML, RESULTS.HTML);
       assert_element_accepts_trusted_type(c[0], c[1], null, "null");
     }, c[0] + "." + c[1] + " accepts string and null after default policy was created.");
--- a/testing/web-platform/tests/trusted-types/block-string-assignment-to-HTMLElement-generic.tentative.html
+++ b/testing/web-platform/tests/trusted-types/block-string-assignment-to-HTMLElement-generic.tentative.html
@@ -66,24 +66,24 @@
   });
 
   // After default policy creation string and null assignments implicitly call createHTML
   let p = window.TrustedTypes.createPolicy("default", { createURL: createURLJS, createScriptURL: createScriptURLJS, createHTML: createHTMLJS }, true);
 
   URLTestCases.forEach(c => {
     test(t => {
       assert_element_accepts_trusted_type(c[0], c[1], INPUTS.URL, RESULTS.URL);
-      assert_element_accepts_trusted_type(c[0], c[1], null, "" + window.location);
+      assert_element_accepts_trusted_type(c[0], c[1], null, window.location.toString().replace(/[^\/]*$/, "null"));
     }, c[0] + "." + c[1] + " accepts string and null after default policy was created");
   });
 
   scriptURLTestCases.forEach(c => {
     test(t => {
       assert_element_accepts_trusted_type(c[0], c[1], INPUTS.SCRIPTURL, RESULTS.SCRIPTURL);
-      assert_element_accepts_trusted_type(c[0], c[1], null, "" + window.location);
+      assert_element_accepts_trusted_type(c[0], c[1], null, window.location.toString().replace(/[^\/]*$/, "null"));
     }, c[0] + "." + c[1] + " accepts string and null after default policy was created");
   });
 
 
   HTMLTestCases.forEach(c => {
     test(t => {
       assert_element_accepts_trusted_type(c[0], c[1], INPUTS.HTML, RESULTS.HTML);
       assert_element_accepts_trusted_type(c[0], c[1], null, "null");