mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326
This commit is contained in:
parent
462c272380
commit
1f531f66ea
5377 changed files with 174916 additions and 84369 deletions
|
@ -1,136 +0,0 @@
|
|||
<!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>
|
|
@ -1,16 +0,0 @@
|
|||
<?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>
|
|
@ -1,19 +0,0 @@
|
|||
<?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>
|
|
@ -1,18 +0,0 @@
|
|||
<?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>
|
|
@ -1,18 +0,0 @@
|
|||
<?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>
|
|
@ -1,18 +0,0 @@
|
|||
<?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>
|
|
@ -1,18 +0,0 @@
|
|||
<?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,10 @@
|
|||
[
|
||||
"registerContentHandler",
|
||||
"isProtocolHandlerRegistered",
|
||||
"isContentHandlerRegistered",
|
||||
"unregisterContentHandler"
|
||||
].forEach(method => {
|
||||
test(() => {
|
||||
assert_false(method in self.navigator);
|
||||
}, method + "() is removed");
|
||||
});
|
|
@ -4,6 +4,25 @@
|
|||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script type="text/javascript">
|
||||
test(function () {
|
||||
for (var i = 0; i < navigator.plugins.length; i++) {
|
||||
const name = navigator.plugins[i].name;
|
||||
const descriptor = Object.getOwnPropertyDescriptor(navigator.plugins, name);
|
||||
assert_false(descriptor.enumerable);
|
||||
assert_false(name in Object.keys(navigator.plugins));
|
||||
assert_in_array(name, Object.getOwnPropertyNames(navigator.plugins));
|
||||
assert_true(name in navigator.plugins);
|
||||
}
|
||||
for (var i = 0; i < navigator.mimeTypes.length; i++) {
|
||||
const type = navigator.mimeTypes[i].type;
|
||||
const descriptor = Object.getOwnPropertyDescriptor(navigator.mimeTypes, type);
|
||||
assert_false(descriptor.enumerable);
|
||||
assert_false(type in Object.keys(navigator.mimeTypes));
|
||||
assert_in_array(type, Object.getOwnPropertyNames(navigator.mimeTypes));
|
||||
assert_true(type in navigator.mimeTypes);
|
||||
}
|
||||
}, "Tests that named properties are not enumerable in navigator.plugins and navigator.mimeTypes");
|
||||
|
||||
test(function () {
|
||||
for (var i = 0; i < navigator.plugins.length; i++) {
|
||||
var plugin = navigator.plugins[i];
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?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>
|
|
@ -1,19 +0,0 @@
|
|||
<?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>
|
|
@ -1,18 +0,0 @@
|
|||
<?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>
|
|
@ -1,18 +0,0 @@
|
|||
<?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>
|
|
@ -1,18 +0,0 @@
|
|||
<?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>
|
|
@ -1,19 +0,0 @@
|
|||
<?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