mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255
This commit is contained in:
parent
b2a5225831
commit
1a81b18b9f
12321 changed files with 544385 additions and 6 deletions
|
@ -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>
|
|
@ -0,0 +1,50 @@
|
|||
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() {
|
||||
assert_false(navigator.taintEnabled());
|
||||
}, "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");
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
importScripts("/resources/testharness.js")
|
||||
importScripts("NavigatorID.js")
|
||||
run_test();
|
||||
done();
|
|
@ -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"
|
||||
}
|
||||
]
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue