diff options
Diffstat (limited to 'testing/web-platform/tests/html/webappapis/system-state-and-capabilities')
24 files changed, 728 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/.gitkeep b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/.gitkeep diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-external-interface/.gitkeep b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-external-interface/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-external-interface/.gitkeep diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/.gitkeep b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/.gitkeep diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.html b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.html new file mode 100644 index 000000000..1956a202c --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.html @@ -0,0 +1,10 @@ +<!doctype html> +<meta charset=utf-8> +<title>NavigatorID</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src=NavigatorID.js></script> +<div id="log"></div> +<script> +run_test(); +</script> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.js b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.js new file mode 100644 index 000000000..cf16c68d4 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.js @@ -0,0 +1,63 @@ +function run_test() { + test(function() { + assert_equals(navigator.appCodeName, "Mozilla"); + }, "appCodeName"); + + test(function() { + assert_equals(typeof navigator.appName, "string", + "navigator.appName should be a string"); + }, "appName"); + + test(function() { + assert_equals(typeof navigator.appVersion, "string", + "navigator.appVersion should be a string"); + }, "appVersion"); + + test(function() { + assert_equals(typeof navigator.platform, "string", + "navigator.platform should be a string"); + }, "platform"); + + test(function() { + assert_equals(navigator.product, "Gecko"); + }, "product"); + + test(function() { + // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=22555 + if ("window" in self) { + // If you identify as WebKit, taintEnabled should not exist. + if (navigator.userAgent.indexOf("WebKit") != -1) { + assert_false("taintEnabled" in navigator); + } + // Otherwise it should exist and return false. + else { + assert_false(navigator.taintEnabled()); + } + } else { + // taintEnabled should not exist in workers. + assert_false("taintEnabled" in navigator); + } + }, "taintEnabled"); + + test(function() { + assert_equals(typeof navigator.userAgent, "string", + "navigator.userAgent should be a string"); + }, "userAgent type"); + + test(function() { + assert_equals(navigator.vendorSub, ""); + }, "vendorSub"); + + async_test(function() { + var request = new XMLHttpRequest(); + request.onload = this.step_func_done(function() { + assert_equals("user-agent: " + navigator.userAgent + "\n", + request.response, + "userAgent should return the value sent in the " + + "User-Agent header"); + }); + request.open("GET", "/XMLHttpRequest/resources/inspect-headers.py?" + + "filter_name=User-Agent"); + request.send(); + }, "userAgent value"); +} diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.worker.js b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.worker.js new file mode 100644 index 000000000..9ba7defa1 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.worker.js @@ -0,0 +1,4 @@ +importScripts("/resources/testharness.js") +importScripts("NavigatorID.js") +run_test(); +done(); diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/contains.json b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/contains.json new file mode 100644 index 000000000..441c24cec --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/contains.json @@ -0,0 +1,22 @@ +[ + { + "id": "client-identification", + "original_id": "client-identification" + }, + { + "id": "custom-handlers", + "original_id": "custom-handlers" + }, + { + "id": "security-and-privacy", + "original_id": "security-and-privacy" + }, + { + "id": "sample-handler-impl", + "original_id": "sample-handler-impl" + }, + { + "id": "manually-releasing-the-storage-mutex", + "original_id": "manually-releasing-the-storage-mutex" + } +]
\ No newline at end of file diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content.html b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content.html new file mode 100644 index 000000000..b6b41c21f --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content.html @@ -0,0 +1,136 @@ +<!DOCTYPE html> +<meta charset='utf-8'> +<title>registerContentHandler()</title> + +<script src='/resources/testharness.js'></script> +<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> + + +<div id='log'></div> + +<script> +test(function () { + assert_idl_attribute(navigator, 'registerContentHandler'); +}, 'the registerContentHandler method should exist on the navigator object'); + +/* Happy path */ +test(function () { + navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s', 'foo'); +}, 'a handler with valid arguments should work'); + + +/* URL argument */ +test(function () { + navigator.registerContentHandler('text/x-unknown-type', '%s', 'foo'); +}, 'a relative URL should work'); + +test(function () { + navigator.registerContentHandler('text/x-unknown-type', location.href + '#%s', 'foo'); +}, 'a URL with a fragment identifier should work'); + +test(function () { + navigator.registerContentHandler('text/x-unknown-type', location.href + '?foo=%s', 'foo'); +}, 'a URL with a query string should work'); + +test(function () { + navigator.registerContentHandler('text/x-unknown-type', location.href + '?foo=%s&bar', 'foo'); +}, 'a URL with a multi-argument query string should work'); + +test(function () { + navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s/bar/baz/', 'foo'); +}, 'a URL with the passed string as a directory name should work'); + +test(function () { + navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s/bar/baz/?foo=1337&bar#baz', 'foo'); +}, 'a URL with the passed string as a directory name followed by a query string and fragment identifier should work'); + +test(function () { + navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s/foo/%s/', 'foo'); +}, 'a URL with the passed string included twice should work'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', '', 'foo') } ); +}, 'an empty url argument should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://%s.com', 'foo') } ); +}, '%s instead of domain name should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://%s.example.com', 'foo') } ); +}, '%s instead of subdomain name should throw syntax_err'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', location.href + '', 'foo') } ); +}, 'a url argument without %s should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://example.com', 'foo') } ); +}, 'a url argument pointing to a different domain name, without %s should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', location.href + '/%', 'foo') } ); +}, 'a url argument without %s (but with %) should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', location.href + '/%a', 'foo') } ); +}, 'a url argument without %s (but with %a) should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://example.com/%s', 'foo') } ); +}, 'a url argument pointing to a different domain name should throw SECURITY_ERR'); + +test(function () { + assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'https://example.com/%s', 'foo') } ); +}, 'a url argument pointing to a different domain name should throw SECURITY_ERR (2)'); + +test(function () { + assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://foobar.example.com/%s', 'foo') } ); +}, 'a url argument pointing to a different domain name should throw SECURITY_ERR (3)'); + +/* Content type argument */ + +/* The following MIME types are handled natively by the browser, and must not + * be possible to override. Note that this list only covers a few basic content + * types. Full lists of content types handled by each browser is found under + * /vendor/. */ + +var blacklist = new Array( + 'image/jpeg', + 'text/html', + 'text/javascript', + 'text/plain'); + +for (var bi=0, bl=blacklist.length; bi<bl; ++bi){ + + test(function () { + assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler(blacklist[bi], location.href + '/%s', 'foo') } ); + }, 'attempting to override the ' + blacklist[bi] + ' MIME type should throw SECURITY_ERR'); + +} + +/* Overriding the following MIME types should be possible. */ +var whitelist = new Array('application/atom+xml', /* For feeds. */ + 'application/rss+xml', /* For feeds. */ + 'application/x-unrecognized', /* Arbitrary MIME types should be overridable. */ + 'text/unrecognized', + 'foo/bar'); + +for (var wi=0, wl=whitelist.length; wi<wl; ++wi){ + + test(function () { + navigator.registerContentHandler(whitelist[wi], location.href + '/%s', 'foo'); + }, 'overriding the ' + whitelist[wi] + ' MIME type should work'); + +} + +</script> + +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/001.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/001.xhtml new file mode 100644 index 000000000..a0d2fa15b --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/001.xhtml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>isContentHandlerRegistered for new content type</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + assert_equals(navigator.isContentHandlerRegistered('application/x-notRegisteredInOtherTCs-001', location.href.replace(/\/[^\/]*$/, "") + '/%s'), 'new'); +}); +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/002.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/002.xhtml new file mode 100644 index 000000000..d5c2ff3e0 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/002.xhtml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>isContentHandlerRegistered for content type that is not yet accepted</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + var ctype = 'application/x-notRegisteredInOtherTCs-002'; + var url = location.href.replace(/\/[^\/]*$/, "") + "/%s"; + navigator.registerContentHandler(ctype, url, 'test'); + assert_equals(navigator.isContentHandlerRegistered(ctype, url), 'declined'); +}); +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/003.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/003.xhtml new file mode 100644 index 000000000..92e7ca8f5 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/003.xhtml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Content type case insensitivity in isContentHandlerRegistered</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + var ctype = 'application/x-notRegisteredInOtherTCs-003', url = location.href.replace(/\/[^\/]*$/, "") + '/%s'; + navigator.registerContentHandler(ctype, url, 'test'); + assert_equals(navigator.isContentHandlerRegistered(ctype.toUpperCase(), url), 'declined'); +}); +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/004.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/004.xhtml new file mode 100644 index 000000000..a82f3506b --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/004.xhtml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Non-matching url in isContentHandlerRegistered</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + var ctype = 'application/x-notRegisteredInOtherTCs-004', url = location.href.replace(/\/[^\/]*$/, "") + '/%s'; + navigator.registerContentHandler(ctype, url, 'test'); + assert_equals(navigator.isContentHandlerRegistered(ctype, 'http://t/core/standards/registerhandler/%s'), 'new'); +}); +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/005.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/005.xhtml new file mode 100644 index 000000000..b8c8b58d1 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/005.xhtml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Invalid characters in content type in isContentHandlerRegistered</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + var ctype = 'application/x-nótRegísteredInOthérTCs-004', url = location.href.replace(/\/[^\/]*$/, "") + '/%s'; + navigator.registerContentHandler(ctype, url, 'test'); + assert_equals(navigator.isContentHandlerRegistered(ctype, 'http://t/core/standards/registerhandler/%s'), 'new'); +}); +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/006.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/006.xhtml new file mode 100644 index 000000000..86d0cff61 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/content/006.xhtml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Blacklisted content type and isContentHandlerRegistered</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + var ctype = 'application/xhtml+xml', url = location.href.replace(/\/[^\/]*$/, "") + '/%s'; + navigator.registerContentHandler(ctype, url, 'test'); + assert_equals(navigator.isContentHandlerRegistered(ctype, 'http://t/core/standards/registerhandler/%s'), 'new'); +}); +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/get-navigatorlanguage-manual.html b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/get-navigatorlanguage-manual.html new file mode 100644 index 000000000..4bdab9112 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/get-navigatorlanguage-manual.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>NavigatorLanguage: navigator.language returns the user's preferred language</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#navigatorlanguage"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<h2>Precondition</h2> +<p>The user agent's preferred language is set as English (en).</p> +<div id="log"></div> +<script> + test(function() { + assert_equals(navigator.language, "en"); + }); +</script> + diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator-indexed.html b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator-indexed.html new file mode 100644 index 000000000..a971fe9d1 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator-indexed.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Test for lack of indexed getter on Navigator</title> +<link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-navigator-object"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + assert_false("0" in window.navigator); + assert_equals(window.navigator[0], undefined); +}, "window.navigator[0] should not exist"); +test(function() { + window.navigator[0] = "pass"; + assert_true("0" in window.navigator); + assert_equals(window.navigator[0], "pass"); +}, "window.navigator[0] should be settable"); +test(function() { + assert_false("-1" in window.navigator); + assert_equals(window.navigator[-1], undefined); +}, "window.navigator[-1] should not exist"); +test(function() { + window.navigator[-1] = "pass"; + assert_true("-1" in window.navigator); + assert_equals(window.navigator[-1], "pass"); +}, "window.navigator[-1] should be settable"); +</script> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigatorlanguage.html b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigatorlanguage.html new file mode 100644 index 000000000..d56df8a3d --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigatorlanguage.html @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>NavigatorLanguage: the most preferred language is the one returned by navigator.language</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#navigatorlanguage"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + test(function() { + assert_true("language" in navigator); + assert_true("languages" in navigator); + + assert_equals(navigator.languages[0], navigator.language, + "navigator.languages is the most preferred language first"); + + }); +</script> + diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol.html b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol.html new file mode 100644 index 000000000..a9ceee5a8 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol.html @@ -0,0 +1,214 @@ +<!DOCTYPE html> +<meta charset='utf-8'> +<title>registerProtocolHandler()</title> + +<script src='/resources/testharness.js'></script> +<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> + +<div id='log'></div> + +<script type='text/javascript'> + +test(function () { + assert_idl_attribute(navigator, 'registerProtocolHandler'); +}, 'the registerProtocolHandler method should exist on the navigator object'); + +test(function () { + navigator.registerProtocolHandler('tel', location.href + '/%s', 'foo'); +}, 'a handler with valid arguments should work'); + + +/* URL argument */ +test(function () { + navigator.registerProtocolHandler('tel', '%s', 'foo'); +}, 'a relative URL should work'); + +test(function () { + navigator.registerProtocolHandler('tel', location.href + '#%s', 'foo'); +}, 'a URL with a fragment identifier should work'); + +test(function () { + navigator.registerProtocolHandler('tel', location.href + '?foo=%s', 'foo'); +}, 'a URL with a query string should work'); + +test(function () { + navigator.registerProtocolHandler('tel', location.href + '?foo=%s&bar', 'foo'); +}, 'a URL with a multi-argument query string should work'); + +test(function () { + navigator.registerProtocolHandler('tel', location.href + '/%s/bar/baz/', 'foo'); +}, 'a URL with the passed string as a directory name should work'); + +test(function () { + navigator.registerProtocolHandler('tel', location.href + '/%s/bar/baz/?foo=1337&bar#baz', 'foo'); +}, 'a URL with the passed string as a directory name followed by a query string and fragment identifier should work'); + +test(function () { + navigator.registerProtocolHandler('tel', location.href + '/%s/foo/%s/', 'foo'); +}, 'a URL with the passed string included twice should work'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', '', 'foo') } ); +}, 'an empty url argument should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://%s.com', 'foo') } ); +}, '%s instead of domain name should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://%s.example.com', 'foo') } ); +}, '%s instead of subdomain name should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', location.href + '', 'foo') } ); +}, 'a url argument without %s should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://example.com', 'foo') } ); +}, 'a url argument pointing to a different domain name, without %s should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', location.href + '/%', 'foo') } ); +}, 'a url argument without %s (but with %) should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', location.href + '/%a', 'foo') } ); +}, 'a url argument without %s (but with %a) should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://example.com/%s', 'foo') } ); +}, 'a url argument pointing to a different domain name should throw SECURITY_ERR'); + +test(function () { + assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'https://example.com/%s', 'foo') } ); +}, 'a url argument pointing to a different domain name should throw SECURITY_ERR (2)'); + +test(function () { + assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://foobar.example.com/%s', 'foo') } ); +}, 'a url argument pointing to a different domain name should throw SECURITY_ERR (3)'); + +test(function () { + assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'mailto:%s@example.com', 'foo') } ); +}, 'looping handlers should throw SECURITY_ERR'); + +test(function () { + assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('sms', 'tel:%s', 'foo') } ); +}, 'a url argument pointing to a non-http[s] scheme should throw SECURITY_ERR due to not being of the same origin'); + +/* Protocol argument */ +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('unrecognized', location.href + '/%a', 'foo') } ); +}, 'a protocol argument containing an unrecognized scheme should throw SECURITY_ERR'); /* This is a whitelist, not a blacklist. */ + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto:', location.href + '/%a', 'foo') } ); +}, 'a protocol argument containing : should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto://', location.href + '/%a', 'foo') } ); +}, 'a protocol argument containing :// should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('http://', location.href + '/%a', 'foo') } ); +}, 'a protocol argument containing http:// should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto' + String.fromCharCode(0), location.href + '/%a', 'foo') } ); +}, 'a protocol argument containing a null character should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailtoo' + String.fromCharCode(8), location.href + '/%a', 'foo') } ); +}, 'a protocol argument containing a backspace character should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto' + String.fromCharCode(10), location.href + '/%a', 'foo') } ); +}, 'a protocol argument containing a LF character should throw SYNTAX_ERR'); + +test(function () { + assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mаilto', location.href + '/%a', 'foo') } ); +}, 'a protocol argument containing non-alphanumeric characters (like a cyrillic “а”) should throw SYNTAX_ERR'); + +test(function () { + navigator.registerProtocolHandler('TEL', location.href + '/%s', 'foo'); +}, 'a protocol argument of “TEL” should be equivalent to “tel”'); + +test(function () { + navigator.registerProtocolHandler('teL', location.href + '/%s', 'foo'); +}, 'a protocol argument of “teL” should be equivalent to “tel”'); + + +/* Overriding any of the following protocols must never be allowed. That would + * break the browser. */ +var blacklist = new Array( + 'about', + 'attachment', + 'blob', + 'chrome', + 'cid', + 'data', + 'file', + 'ftp', + 'http', + 'https', + 'javascript', + 'livescript', + 'mid', + 'mocha', + 'opera', + 'operamail', + 'res', + 'resource', + 'shttp', + 'tcl', + 'vbscript', + 'view-source', + 'ws', + 'wss', + 'wyciwyg'); + +for ( var bi=0, bl=blacklist.length; bi<bl; ++bi ){ + + test(function () { + assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler(blacklist[bi], location.href + '/%s', 'foo') } ); + }, 'attempting to override the ' + blacklist[bi] + ' 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. */ +var whitelist = new Array( + 'geo', + 'im', + 'irc', + 'ircs', + 'mailto', + 'mms', + 'news', + 'nntp', + 'sms', + 'smsto', + 'tel', + 'urn', + 'webcal', + 'wtai', + 'xmpp'); + +for ( var wi=0, wl=whitelist.length; wi<wl; ++wi ){ + + test(function () { + navigator.registerProtocolHandler(whitelist[wi], location.href + '/%s', 'foo'); + assert_true(true); + }, 'overriding the ' + whitelist[wi] + ' protocol should work'); + +} +</script> + +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/001.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/001.xhtml new file mode 100644 index 000000000..ce9ee1eb0 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/001.xhtml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>isProtocolHandlerRegistered for new protocol</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + var dir_uri = location.href.replace(/\/[^\/]*$/, ""); + assert_equals(navigator.isProtocolHandlerRegistered('web+CustomProtocolOne', dir_uri + '/%s'), 'new'); +}); +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/002.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/002.xhtml new file mode 100644 index 000000000..ce2c8dc0d --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/002.xhtml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>isProtocolHandlerRegistered for protocol that is not yet accepted</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + var scheme = 'web+CustomProtocolTwo'; + var url = location.href.replace(/\/[^\/]*$/, "") + '/%s'; + navigator.registerProtocolHandler(scheme, url, 'Ignore dialog or decline it'); + assert_equals(navigator.isProtocolHandlerRegistered(scheme, url), 'declined') +}) +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/003.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/003.xhtml new file mode 100644 index 000000000..035d5b9a6 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/003.xhtml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Protocol case insensitivity in isProtocolHandlerRegistered</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + var scheme = 'web+CustomProtocolTree', url = location.href.replace(/\/[^\/]*$/, "") + '/%s'; + navigator.registerProtocolHandler(scheme, url, 'Ignore dialog or decline it'); + assert_equals(navigator.isProtocolHandlerRegistered(scheme.toUpperCase(), url), 'declined'); +}); +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/004.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/004.xhtml new file mode 100644 index 000000000..3fd14dd12 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/004.xhtml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Non-matching url in isProtocolHandlerRegistered</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + var scheme = 'web+CustomProtocolFour', url = location.href.replace(/\/[^\/]*$/, "") + '/%s'; + navigator.registerProtocolHandler(scheme, url, 'Ignore dialog'); + assert_equals(navigator.isProtocolHandlerRegistered(scheme, 'http://t/core/standards/registerhandler/%s'), 'new'); +}); +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/005.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/005.xhtml new file mode 100644 index 000000000..894ff4a6a --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/005.xhtml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Invalid characters in protocol scheme and isProtocolHandlerRegistered</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + var scheme = 'web+CústomPrótocolFíve', url = location.href.replace(/\/[^\/]*$/, "") + '/%s'; + navigator.registerProtocolHandler(scheme, url, 'Ignore dialog or decline it'); + assert_equals(navigator.isProtocolHandlerRegistered(scheme, url), 'new'); +}); +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/006.xhtml b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/006.xhtml new file mode 100644 index 000000000..7529a7eb2 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/protocol/006.xhtml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Scheme outside white list and isProtocolHandlerRegistered</title> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script type="application/ecmascript"> +test(function() { + var dir_uri = location.href.replace(/\/[^\/]*$/, ""); + var scheme = 'http', url = dir_uri + '/%s'; + navigator.registerProtocolHandler(scheme, url, 'Ignore dialog or decline it'); + assert_equals(navigator.isProtocolHandlerRegistered(scheme, url), 'new'); +}); +</script> +</head> +<body> +<div id="log"></div> +</body> +</html> |