Bug 1636115 [wpt PR 23458] - HTML: registerProtocolHandler() lowercases scheme argument, a=testonly
☠☠ backed out by 267cd03f6f5c ☠ ☠
authorAnne van Kesteren <annevk@annevk.nl>
Wed, 13 May 2020 09:49:17 +0000
changeset 530120 8a0d48c8c1b715e7a4c5aec3109c7b9043a06cbd
parent 530119 11648974ec00d31d05d8271601a6170b7b2ca342
child 530121 d57c402d46bb02fd9c7f0dbf6a2b69d1e1d7d412
push id116003
push userwptsync@mozilla.com
push dateThu, 14 May 2020 19:04:08 +0000
treeherderautoland@7baa72e0d62c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1636115, 23458
milestone78.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 1636115 [wpt PR 23458] - HTML: registerProtocolHandler() lowercases scheme argument, a=testonly Automatic update from web-platform-tests registerProtocolHandler(): lowercasing scheme and exception order For https://github.com/whatwg/html/issues/3828. Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com> -- wpt-commits: 7e3d82f887984c49c29366a0f936b0d123c6cbe6 wpt-pr: 23458
testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol.https.html
--- a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol.https.html
+++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol.https.html
@@ -6,94 +6,94 @@
 <script src='/resources/testharnessreport.js'></script>
 
 <noscript><p>Enable JavaScript and reload.</p></noscript>
 
 <p><strong>Note:</strong> If your browser limits the number of handler
 registration requests on a page, you might need to disable or significantly
 increase that limit for the tests below to run.</p>
 
-<script type='text/javascript'>
+<script>
 test(() => {
   assert_idl_attribute(navigator, 'registerProtocolHandler');
 }, 'the registerProtocolHandler method should exist on the navigator object');
 
 test(() => {
   assert_idl_attribute(navigator, 'unregisterProtocolHandler');
 }, 'the unregisterProtocolHandler method should exist on the navigator object');
 
 /* URL argument */
-const valid_urls = [
+[
   '%s',
   'foo/%s',
   location.href + '/%s',
   location.href + '#%s',
   location.href + '?foo=%s',
   location.href + '?foo=%s&bar',
   location.href + '/%s/bar/baz/',
   location.href + '/%s/bar/baz/?foo=1337&bar#baz',
   location.href + '/%s/foo/%s/',
-];
-for (const url of valid_urls) {
+].forEach(url => {
   test(() => {
     navigator.registerProtocolHandler('tel', url, 'foo');
   }, 'registerProtocolHandler: Valid URL "' + url + '" should work.');
 
   test(() => {
     navigator.unregisterProtocolHandler('tel', url);
   }, 'unregisterProtocolHandler: Valid URL "' + url + '" should work.');
-}
+});
 
-const invalid_urls1 = [
+/* Invalid URLs */
+[
   '',
   '%S',
   location.href + '',
   location.href + '/%',
   location.href + '/%a',
   'http://example.com',
   'http://[v8.:::]//url=%s',
-];
-
-for (const url of invalid_urls1) {
+  'https://test:test/',
+].forEach(url => {
   test(() => {
     assert_throws_dom('SYNTAX_ERR', () => { navigator.registerProtocolHandler('mailto', url, 'foo'); });
-  }, 'registerProtocolHandler: Invalid URL "' + url + '" should throw SYNTAX_ERR.');
+    assert_throws_dom('SECURITY_ERR', () => { navigator.registerProtocolHandler('x', url, 'foo'); });
+  }, `registerProtocolHandler: Invalid URL "${url}" should throw (but after scheme)`);
 
   test(() => {
     assert_throws_dom('SYNTAX_ERR', () => { navigator.unregisterProtocolHandler('mailto', url); });
-  }, 'unregisterProtocolHandler: Invalid URL "' + url + '" should throw SYNTAX_ERR.');
-}
+    assert_throws_dom('SECURITY_ERR', () => { navigator.registerProtocolHandler('x', url, 'foo'); });
+  }, `unregisterProtocolHandler: Invalid URL "${url}" should throw (but after scheme)`);
+});
 
-const invalid_urls2 = [
+[
   'http://%s.com',
   'http://%s.example.com',
   'http://example.com/%s',
   'https://example.com/%s',
   'http://foobar.example.com/%s',
   'mailto:%s@example.com',
   'mailto:%s',
   `ftp://${location.host}/%s`,
   `chrome://${location.host}/%s`,
   `foo://${location.host}/%s`,
-];
-for (const url of invalid_urls2) {
+].forEach(url => {
   test(() => {
     assert_throws_dom('SECURITY_ERR', () => { navigator.registerProtocolHandler('mailto', url, 'foo'); });
   }, 'registerProtocolHandler: Invalid URL "' + url + '" should throw SECURITY_ERR.');
 
   test(() => {
     assert_throws_dom('SECURITY_ERR', () => { navigator.unregisterProtocolHandler('mailto', url); });
   }, 'unregisterProtocolHandler: Invalid URL "' + url + '" should throw SECURITY_ERR.');
-}
+});
 
 /* Protocol argument */
 
 /* Overriding any of the following protocols must never be allowed. That would
  * break the browser. */
-const denylist = [
+[
   'about',
   'attachment',
   'blob',
   'chrome',
   'cid',
   'data',
   'file',
   'ftp',
@@ -130,33 +130,32 @@ const denylist = [
   'foo',
   'fweb+oo',
   /* web+ prefixed schemes must be followed by 1+ ascii alphas */
   'web+',
   'web+1',
   'web+dots.are.forbidden',
   'web+dashes-are-forbidden',
   'web+digits123areforbidden',
-  'web+UpperCasesAreForbidden',
-];
-for (const scheme of denylist) {
+].forEach(scheme => {
   test(() => {
-    assert_throws_dom('SECURITY_ERR', () => { navigator.registerProtocolHandler(scheme, location.href + '/%s', 'foo'); });
+    // https://test:test/ does not parse and does not contain %s, but the scheme check happens first
+    assert_throws_dom('SECURITY_ERR', () => { navigator.registerProtocolHandler(scheme, 'https://test:test/', 'foo'); });
   }, 'registerProtocolHandler: Attempting to override the "' + scheme + '" protocol should throw SECURITY_ERR.');
 
   test(() => {
-    assert_throws_dom('SECURITY_ERR', () => { navigator.unregisterProtocolHandler(scheme, location.href + '/%s'); });
+    assert_throws_dom('SECURITY_ERR', () => { navigator.unregisterProtocolHandler(scheme, 'https://test:test/'); });
   }, 'unregisterProtocolHandler: Attempting to override the "' + scheme + '" protocol should throw SECURITY_ERR.');
-}
+});
 
 /* The following protocols must be possible to override.
  * We're just testing that the call goes through here. Whether or not they
  * actually work as handlers is covered by the interactive tests. */
 
-const safelist = [
+[
   /* safelisted schemes listed in
    * https://html.spec.whatwg.org/multipage/system-state.html#safelisted-scheme */
   'bitcoin',
   'geo',
   'im',
   'irc',
   'ircs',
   'magnet',
@@ -179,19 +178,21 @@ const safelist = [
   'Irc',
   'MagneT',
   'SmsTo',
   'TEL',
   'teL',
   'WebCAL',
   'WTAI',
   'web+myprotocol',
-];
-for (const scheme of safelist) {
+  'web+UpperCasedIsLowercased',
+  'WEB+seeabove',
+  'WeB+SeEaBoVe'
+].forEach(scheme => {
   test(() => {
     navigator.registerProtocolHandler(scheme, location.href + '/%s', "foo");
   }, 'registerProtocolHandler: overriding the "' + scheme + '" protocol should work');
 
   test(() => {
     navigator.unregisterProtocolHandler(scheme, location.href + '/%s');
   }, 'unregisterProtocolHandler: overriding the "' + scheme + '" protocol should work');
-}
+});
 </script>