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
tests/wpt/web-platform-tests/html/webappapis/.gitkeep
Normal file
0
tests/wpt/web-platform-tests/html/webappapis/.gitkeep
Normal file
306
tests/wpt/web-platform-tests/html/webappapis/atob/base64.html
Normal file
306
tests/wpt/web-platform-tests/html/webappapis/atob/base64.html
Normal file
|
@ -0,0 +1,306 @@
|
|||
<!doctype html>
|
||||
<!-- Originally developed by Aryeh Gregor, funded by Google. Copyright belongs
|
||||
to Google. -->
|
||||
<title>atob()/btoa() tests</title>
|
||||
<meta charset=utf-8>
|
||||
<div id=log></div>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script>
|
||||
/**
|
||||
* btoa() as defined by the HTML5 spec, which mostly just references RFC4648.
|
||||
*/
|
||||
function mybtoa(s) {
|
||||
// String conversion as required by WebIDL.
|
||||
s = String(s);
|
||||
|
||||
// "The btoa() method must throw an INVALID_CHARACTER_ERR exception if the
|
||||
// method's first argument contains any character whose code point is
|
||||
// greater than U+00FF."
|
||||
for (var i = 0; i < s.length; i++) {
|
||||
if (s.charCodeAt(i) > 255) {
|
||||
return "INVALID_CHARACTER_ERR";
|
||||
}
|
||||
}
|
||||
|
||||
var out = "";
|
||||
for (var i = 0; i < s.length; i += 3) {
|
||||
var groupsOfSix = [undefined, undefined, undefined, undefined];
|
||||
groupsOfSix[0] = s.charCodeAt(i) >> 2;
|
||||
groupsOfSix[1] = (s.charCodeAt(i) & 0x03) << 4;
|
||||
if (s.length > i + 1) {
|
||||
groupsOfSix[1] |= s.charCodeAt(i + 1) >> 4;
|
||||
groupsOfSix[2] = (s.charCodeAt(i + 1) & 0x0f) << 2;
|
||||
}
|
||||
if (s.length > i + 2) {
|
||||
groupsOfSix[2] |= s.charCodeAt(i + 2) >> 6;
|
||||
groupsOfSix[3] = s.charCodeAt(i + 2) & 0x3f;
|
||||
}
|
||||
for (var j = 0; j < groupsOfSix.length; j++) {
|
||||
if (typeof groupsOfSix[j] == "undefined") {
|
||||
out += "=";
|
||||
} else {
|
||||
out += btoaLookup(groupsOfSix[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup table for mybtoa(), which converts a six-bit number into the
|
||||
* corresponding ASCII character.
|
||||
*/
|
||||
function btoaLookup(idx) {
|
||||
if (idx < 26) {
|
||||
return String.fromCharCode(idx + 'A'.charCodeAt(0));
|
||||
}
|
||||
if (idx < 52) {
|
||||
return String.fromCharCode(idx - 26 + 'a'.charCodeAt(0));
|
||||
}
|
||||
if (idx < 62) {
|
||||
return String.fromCharCode(idx - 52 + '0'.charCodeAt(0));
|
||||
}
|
||||
if (idx == 62) {
|
||||
return '+';
|
||||
}
|
||||
if (idx == 63) {
|
||||
return '/';
|
||||
}
|
||||
// Throw INVALID_CHARACTER_ERR exception here -- won't be hit in the tests.
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of atob() according to the HTML spec, except that instead of
|
||||
* throwing INVALID_CHARACTER_ERR we return null.
|
||||
*/
|
||||
function myatob(input) {
|
||||
// WebIDL requires DOMStrings to just be converted using ECMAScript
|
||||
// ToString, which in our case amounts to calling String().
|
||||
input = String(input);
|
||||
|
||||
// "Remove all space characters from input."
|
||||
input = input.replace(/[ \t\n\f\r]/g, "");
|
||||
|
||||
// "If the length of input divides by 4 leaving no remainder, then: if
|
||||
// input ends with one or two U+003D EQUALS SIGN (=) characters, remove
|
||||
// them from input."
|
||||
if (input.length % 4 == 0 && /==?$/.test(input)) {
|
||||
input = input.replace(/==?$/, "");
|
||||
}
|
||||
|
||||
// "If the length of input divides by 4 leaving a remainder of 1, throw an
|
||||
// INVALID_CHARACTER_ERR exception and abort these steps."
|
||||
//
|
||||
// "If input contains a character that is not in the following list of
|
||||
// characters and character ranges, throw an INVALID_CHARACTER_ERR
|
||||
// exception and abort these steps:
|
||||
//
|
||||
// U+002B PLUS SIGN (+)
|
||||
// U+002F SOLIDUS (/)
|
||||
// U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9)
|
||||
// U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z
|
||||
// U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z"
|
||||
if (input.length % 4 == 1
|
||||
|| !/^[+/0-9A-Za-z]*$/.test(input)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// "Let output be a string, initially empty."
|
||||
var output = "";
|
||||
|
||||
// "Let buffer be a buffer that can have bits appended to it, initially
|
||||
// empty."
|
||||
//
|
||||
// We append bits via left-shift and or. accumulatedBits is used to track
|
||||
// when we've gotten to 24 bits.
|
||||
var buffer = 0;
|
||||
var accumulatedBits = 0;
|
||||
|
||||
// "While position does not point past the end of input, run these
|
||||
// substeps:"
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
// "Find the character pointed to by position in the first column of
|
||||
// the following table. Let n be the number given in the second cell of
|
||||
// the same row."
|
||||
//
|
||||
// "Append to buffer the six bits corresponding to number, most
|
||||
// significant bit first."
|
||||
//
|
||||
// atobLookup() implements the table from the spec.
|
||||
buffer <<= 6;
|
||||
buffer |= atobLookup(input[i]);
|
||||
|
||||
// "If buffer has accumulated 24 bits, interpret them as three 8-bit
|
||||
// big-endian numbers. Append the three characters with code points
|
||||
// equal to those numbers to output, in the same order, and then empty
|
||||
// buffer."
|
||||
accumulatedBits += 6;
|
||||
if (accumulatedBits == 24) {
|
||||
output += String.fromCharCode((buffer & 0xff0000) >> 16);
|
||||
output += String.fromCharCode((buffer & 0xff00) >> 8);
|
||||
output += String.fromCharCode(buffer & 0xff);
|
||||
buffer = accumulatedBits = 0;
|
||||
}
|
||||
|
||||
// "Advance position by one character."
|
||||
}
|
||||
|
||||
// "If buffer is not empty, it contains either 12 or 18 bits. If it
|
||||
// contains 12 bits, discard the last four and interpret the remaining
|
||||
// eight as an 8-bit big-endian number. If it contains 18 bits, discard the
|
||||
// last two and interpret the remaining 16 as two 8-bit big-endian numbers.
|
||||
// Append the one or two characters with code points equal to those one or
|
||||
// two numbers to output, in the same order."
|
||||
if (accumulatedBits == 12) {
|
||||
buffer >>= 4;
|
||||
output += String.fromCharCode(buffer);
|
||||
} else if (accumulatedBits == 18) {
|
||||
buffer >>= 2;
|
||||
output += String.fromCharCode((buffer & 0xff00) >> 8);
|
||||
output += String.fromCharCode(buffer & 0xff);
|
||||
}
|
||||
|
||||
// "Return output."
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* A lookup table for atob(), which converts an ASCII character to the
|
||||
* corresponding six-bit number.
|
||||
*/
|
||||
function atobLookup(chr) {
|
||||
if (/[A-Z]/.test(chr)) {
|
||||
return chr.charCodeAt(0) - "A".charCodeAt(0);
|
||||
}
|
||||
if (/[a-z]/.test(chr)) {
|
||||
return chr.charCodeAt(0) - "a".charCodeAt(0) + 26;
|
||||
}
|
||||
if (/[0-9]/.test(chr)) {
|
||||
return chr.charCodeAt(0) - "0".charCodeAt(0) + 52;
|
||||
}
|
||||
if (chr == "+") {
|
||||
return 62;
|
||||
}
|
||||
if (chr == "/") {
|
||||
return 63;
|
||||
}
|
||||
// Throw exception; should not be hit in tests
|
||||
}
|
||||
|
||||
function btoaException(input) {
|
||||
input = String(input);
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
if (input.charCodeAt(i) > 255) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function testBtoa(input) {
|
||||
// "The btoa() method must throw an INVALID_CHARACTER_ERR exception if the
|
||||
// method's first argument contains any character whose code point is
|
||||
// greater than U+00FF."
|
||||
var normalizedInput = String(input);
|
||||
for (var i = 0; i < normalizedInput.length; i++) {
|
||||
if (normalizedInput.charCodeAt(i) > 255) {
|
||||
assert_throws("InvalidCharacterError", function() { btoa(input); },
|
||||
"Code unit " + i + " has value " + normalizedInput.charCodeAt(i) + ", which is greater than 255");
|
||||
return;
|
||||
}
|
||||
}
|
||||
assert_equals(btoa(input), mybtoa(input));
|
||||
assert_equals(atob(btoa(input)), String(input), "atob(btoa(input)) must be the same as String(input)");
|
||||
}
|
||||
|
||||
var tests = ["עברית", "", "ab", "abc", "abcd", "abcde",
|
||||
// This one is thrown in because IE9 seems to fail atob(btoa()) on it. Or
|
||||
// possibly to fail btoa(). I actually can't tell what's happening here,
|
||||
// but it doesn't hurt.
|
||||
"\xff\xff\xc0",
|
||||
// Is your DOM implementation binary-safe?
|
||||
"\0a", "a\0b",
|
||||
// WebIDL tests.
|
||||
undefined, null, 7, 12, 1.5, true, false, NaN, +Infinity, -Infinity, 0, -0,
|
||||
{toString: function() { return "foo" }},
|
||||
];
|
||||
for (var i = 0; i < 258; i++) {
|
||||
tests.push(String.fromCharCode(i));
|
||||
}
|
||||
tests.push(String.fromCharCode(10000));
|
||||
tests.push(String.fromCharCode(65534));
|
||||
tests.push(String.fromCharCode(65535));
|
||||
|
||||
// This is supposed to be U+10000.
|
||||
tests.push(String.fromCharCode(0xd800, 0xdc00));
|
||||
tests = tests.map(
|
||||
function(elem) {
|
||||
var expected = mybtoa(elem);
|
||||
if (expected === "INVALID_CHARACTER_ERR") {
|
||||
return ["btoa(" + format_value(elem) + ") must raise INVALID_CHARACTER_ERR", elem];
|
||||
}
|
||||
return ["btoa(" + format_value(elem) + ") == " + format_value(mybtoa(elem)), elem];
|
||||
}
|
||||
);
|
||||
|
||||
var everything = "";
|
||||
for (var i = 0; i < 256; i++) {
|
||||
everything += String.fromCharCode(i);
|
||||
}
|
||||
tests.push(["btoa(first 256 code points concatenated)", everything]);
|
||||
|
||||
generate_tests(testBtoa, tests);
|
||||
|
||||
function testAtob(input) {
|
||||
var expected = myatob(input);
|
||||
if (expected === null) {
|
||||
assert_throws("InvalidCharacterError", function() { atob(input) });
|
||||
return;
|
||||
}
|
||||
|
||||
assert_equals(atob(input), expected);
|
||||
}
|
||||
|
||||
var tests = ["", "abcd", " abcd", "abcd ", " abcd===", "abcd=== ",
|
||||
"abcd ===", "a", "ab", "abc", "abcde", String.fromCharCode(0xd800, 0xdc00),
|
||||
"=", "==", "===", "====", "=====",
|
||||
"a=", "a==", "a===", "a====", "a=====",
|
||||
"ab=", "ab==", "ab===", "ab====", "ab=====",
|
||||
"abc=", "abc==", "abc===", "abc====", "abc=====",
|
||||
"abcd=", "abcd==", "abcd===", "abcd====", "abcd=====",
|
||||
"abcde=", "abcde==", "abcde===", "abcde====", "abcde=====",
|
||||
"=a", "=a=", "a=b", "a=b=", "ab=c", "ab=c=", "abc=d", "abc=d=",
|
||||
// With whitespace
|
||||
"ab\tcd", "ab\ncd", "ab\fcd", "ab\rcd", "ab cd", "ab\u00a0cd",
|
||||
"ab\t\n\f\r cd", " \t\n\f\r ab\t\n\f\r cd\t\n\f\r ",
|
||||
"ab\t\n\f\r =\t\n\f\r =\t\n\f\r ",
|
||||
// Test if any bits are set at the end. These should all be fine, since
|
||||
// they end with A, which becomes 0:
|
||||
"A", "/A", "//A", "///A", "////A",
|
||||
// These are all bad, since they end in / (= 63, all bits set) but their
|
||||
// length isn't a multiple of four characters, so they can't be output by
|
||||
// btoa(). Thus one might expect some UAs to throw exceptions or otherwise
|
||||
// object, since they could never be output by btoa(), so they're good to
|
||||
// test.
|
||||
"/", "A/", "AA/", "AAAA/",
|
||||
// But this one is possible:
|
||||
"AAA/",
|
||||
// Binary-safety tests
|
||||
"\0nonsense", "abcd\0nonsense",
|
||||
// WebIDL tests
|
||||
undefined, null, 7, 12, 1.5, true, false, NaN, +Infinity, -Infinity, 0, -0,
|
||||
{toString: function() { return "foo" }},
|
||||
{toString: function() { return "abcd" }},
|
||||
];
|
||||
tests = tests.map(
|
||||
function(elem) {
|
||||
if (myatob(elem) === null) {
|
||||
return ["atob(" + format_value(elem) + ") must raise InvalidCharacterError", elem];
|
||||
}
|
||||
return ["atob(" + format_value(elem) + ") == " + format_value(myatob(elem)), elem];
|
||||
}
|
||||
);
|
||||
|
||||
generate_tests(testAtob, tests);
|
||||
</script>
|
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
{
|
||||
"id": "definitions-1",
|
||||
"original_id": "definitions-1"
|
||||
},
|
||||
{
|
||||
"id": "processing-model-3",
|
||||
"original_id": "processing-model-3"
|
||||
},
|
||||
{
|
||||
"id": "generic-task-sources",
|
||||
"original_id": "generic-task-sources"
|
||||
}
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<title>HTMLBodyElement.onload</title>
|
||||
<link rel="author" title="Boris Zbarsky" href="mailto:bzbarsky@mit.edu">
|
||||
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#handler-window-onload">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test("body.onload should set the window.onload handler")
|
||||
window.onload = t.step_func(function() {
|
||||
assert_unreached("This handler should be overwritten.")
|
||||
})
|
||||
var b = document.createElement("body")
|
||||
b.onload = t.step_func(function(e) {
|
||||
assert_equals(e.currentTarget, window,
|
||||
"The event should be fired at the window.")
|
||||
t.done()
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,18 @@
|
|||
[
|
||||
{
|
||||
"id": "event-handler-attributes",
|
||||
"original_id": "event-handler-attributes"
|
||||
},
|
||||
{
|
||||
"id": "event-handlers-on-elements-document-objects-and-window-objects",
|
||||
"original_id": "event-handlers-on-elements,-document-objects,-and-window-objects"
|
||||
},
|
||||
{
|
||||
"id": "event-firing",
|
||||
"original_id": "event-firing"
|
||||
},
|
||||
{
|
||||
"id": "events-and-the-window-object",
|
||||
"original_id": "events-and-the-window-object"
|
||||
}
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Event handler with labels</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body onload="javascript:
|
||||
for (var i = 0; i < 2; ++i) {
|
||||
for (var j = 0; j < 2; ++j) {
|
||||
t.step(function() {
|
||||
assert_equals(i, 0);
|
||||
assert_equals(j, 0);
|
||||
});
|
||||
break javascript;
|
||||
}
|
||||
}
|
||||
t.done();
|
||||
">
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test("Event handlers starting with 'javascript:' should treat that as a label.");
|
||||
</script>
|
|
@ -0,0 +1,65 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Event handler invocation order</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var objects = [{}, function() {}, new Number(42), new String()];
|
||||
var primitives = [42, null, undefined, ""];
|
||||
objects.forEach(function(object) {
|
||||
var t = async_test("Event handler listeners should be registered when they " +
|
||||
"are first set to an object value (" +
|
||||
format_value(object) + ").");
|
||||
t.step(function() {
|
||||
var i = 0;
|
||||
var uncalled = "t.step(function() { assert_unreached('First event handler.') })"
|
||||
var button = document.createElement('button');
|
||||
button.onclick = object; // event handler listener is registered here
|
||||
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 2) }), false);
|
||||
button.setAttribute('onclick', uncalled);
|
||||
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false);
|
||||
button.onclick = t.step_func(function () { assert_equals(++i, 1); });
|
||||
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false);
|
||||
button.click()
|
||||
assert_equals(button.getAttribute("onclick"), uncalled)
|
||||
assert_equals(i, 4);
|
||||
t.done()
|
||||
});
|
||||
});
|
||||
primitives.forEach(function(primitive) {
|
||||
var t = async_test("Event handler listeners should be registered when they " +
|
||||
"are first set to an object value (" +
|
||||
format_value(primitive) + ").");
|
||||
t.step(function() {
|
||||
var i = 0;
|
||||
var uncalled = "t.step(function() { assert_unreached('First event handler.') })"
|
||||
var button = document.createElement('button');
|
||||
button.onclick = primitive;
|
||||
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 1) }), false);
|
||||
button.setAttribute('onclick', uncalled); // event handler listener is registered here
|
||||
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false);
|
||||
button.onclick = t.step_func(function () { assert_equals(++i, 2); });
|
||||
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false);
|
||||
button.click()
|
||||
assert_equals(button.getAttribute("onclick"), uncalled)
|
||||
assert_equals(i, 4);
|
||||
t.done()
|
||||
});
|
||||
});
|
||||
var t = async_test("Event handler listeners should be registered when they " +
|
||||
"are first set to an object value.");
|
||||
t.step(function() {
|
||||
var i = 0;
|
||||
var uncalled = "t.step(function() { assert_unreached('First event handler.') })"
|
||||
var button = document.createElement('button');
|
||||
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 1) }), false);
|
||||
button.setAttribute('onclick', uncalled); // event handler listener is registered here
|
||||
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false);
|
||||
button.onclick = t.step_func(function () { assert_equals(++i, 2); });
|
||||
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false);
|
||||
button.click()
|
||||
assert_equals(button.getAttribute("onclick"), uncalled)
|
||||
assert_equals(i, 4);
|
||||
t.done()
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,32 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - addEventListener</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var ran = false;
|
||||
// spec doesn't say to fire an event so this should do nothing
|
||||
window.addEventListener('error', t.step_func(function(e){
|
||||
ran = true;
|
||||
}), false);
|
||||
</script>
|
||||
<script>
|
||||
undefined_variable;
|
||||
</script>
|
||||
<script>
|
||||
for (;) {}
|
||||
</script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_false(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,37 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title><body onerror> - compile error in <script src=data:...></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
</script>
|
||||
<body onerror="
|
||||
t.step(function(){
|
||||
ran = true;
|
||||
assert_equals(typeof event, 'string', 'first arg');
|
||||
assert_equals(source, 'data:text/javascript,for(;){}', 'second arg');
|
||||
assert_equals(typeof lineno, 'number', 'third arg');
|
||||
});
|
||||
t_col.step(function() {
|
||||
assert_equals(typeof column, 'number', 'fourth arg');
|
||||
});
|
||||
">
|
||||
<div id=log></div>
|
||||
<script src="data:text/javascript,for(;){}"></script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
t_col.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title><body onerror> - compile error in <script></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
</script>
|
||||
<body onerror="
|
||||
t.step(function(){
|
||||
ran = true;
|
||||
assert_equals(typeof event, 'string', 'first arg');
|
||||
assert_equals(source, location.href, 'second arg');
|
||||
assert_equals(typeof lineno, 'number', 'third arg');
|
||||
});
|
||||
t_col.step(function() {
|
||||
assert_equals(typeof column, 'number', 'fourth arg');
|
||||
});
|
||||
">
|
||||
<div id=log></div>
|
||||
<script>
|
||||
for(;) {}
|
||||
</script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
t_col.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title><body onerror> - runtime error in <script></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
</script>
|
||||
<body onerror="
|
||||
t.step(function(){
|
||||
ran = true;
|
||||
assert_equals(typeof event, 'string', 'first arg');
|
||||
assert_equals(source, location.href, 'second arg');
|
||||
assert_equals(typeof lineno, 'number', 'third arg');
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof column, 'number', 'fourth arg');
|
||||
});
|
||||
">
|
||||
<div id=log></div>
|
||||
<script>
|
||||
undefined_variable;
|
||||
</script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
t_col.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,34 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - compile error in cross-origin setInterval</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
var interval;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
clearInterval(interval);
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(a, 'Script error.', 'first arg');
|
||||
assert_equals(b, '', 'second arg');
|
||||
assert_equals(c, 0, 'third arg');
|
||||
});
|
||||
function col_check() {
|
||||
assert_equals(col_value, 0, 'fourth arg');
|
||||
t_col.done();
|
||||
}
|
||||
var script = document.createElement('script');
|
||||
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/syntax-error-in-setInterval.js');
|
||||
document.body.appendChild(script);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,32 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - compile error in cross-origin setTimeout</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(a, 'Script error.', 'first arg');
|
||||
assert_equals(b, '', 'second arg');
|
||||
assert_equals(c, 0, 'third arg');
|
||||
});
|
||||
function col_check() {
|
||||
assert_equals(col_value, 0, 'fourth arg');
|
||||
t_col.done();
|
||||
}
|
||||
var script = document.createElement('script');
|
||||
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/syntax-error-in-setTimeout.js');
|
||||
document.body.appendChild(script);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - compile error in <script src=//www1...></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(a, 'Script error.', 'first arg');
|
||||
assert_equals(b, '', 'second arg');
|
||||
assert_equals(c, 0, 'third arg');
|
||||
});
|
||||
var script = document.createElement('script');
|
||||
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/syntax-error.js');
|
||||
document.body.appendChild(script);
|
||||
onload = function(){
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(col_value, 0, 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,36 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - compile error in <script src=data:...></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, 'data:text/javascript,for(;) {}', 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
</script>
|
||||
<script src="data:text/javascript,for(;) {}"></script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, 'number', 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - compile error in attribute</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, location.href, 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
</script>
|
||||
<p onclick="{"></p>
|
||||
<script>
|
||||
t.step(function(){
|
||||
var ev = document.createEvent('Event');
|
||||
ev.initEvent('click', false, false);
|
||||
document.querySelector('p').dispatchEvent(ev);
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, 'number', 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,28 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - compile error in <body onerror></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var ran = false;
|
||||
window.onerror = t.step_func(function(){
|
||||
ran = true;
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body onerror="{"><!-- sets the event handler to null before compiling -->
|
||||
<div id=log></div>
|
||||
<script>
|
||||
for(;) {}
|
||||
</script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_false(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - compile error in setInterval</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
var interval;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
clearInterval(interval);
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, location.href, 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
interval = setInterval("{", 10);
|
||||
setTimeout(function(){
|
||||
t.step(function(){
|
||||
clearInterval(interval);
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, 'number', 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
}, 20);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,36 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - compile error in setTimeout</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, location.href, 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
setTimeout("{", 10);
|
||||
setTimeout(function(){
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, 'number', 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
}, 20);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,36 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - compile error in <script src=...></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, document.querySelector('script[src="support/syntax-error.js"]').src, 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
</script>
|
||||
<script src="support/syntax-error.js"></script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, 'number', 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - compile error in <script></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, location.href, 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
for(;) {}
|
||||
</script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, 'number', 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,28 @@
|
|||
[
|
||||
{
|
||||
"id": "definitions-0",
|
||||
"original_id": "definitions-0"
|
||||
},
|
||||
{
|
||||
"id": "calling-scripts",
|
||||
"original_id": "calling-scripts"
|
||||
},
|
||||
{
|
||||
"id": "creating-scripts",
|
||||
"original_id": "creating-scripts"
|
||||
},
|
||||
{
|
||||
"id": "killing-scripts",
|
||||
"original_id": "killing-scripts"
|
||||
},
|
||||
{
|
||||
"id": "runtime-script-errors",
|
||||
"original_id": "runtime-script-errors",
|
||||
"children": [
|
||||
{
|
||||
"id": "runtime-script-errors-in-documents",
|
||||
"original_id": "runtime-script-errors-in-documents"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,34 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - runtime error in cross-origin setInterval</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
var interval;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
clearInterval(interval);
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(a, 'Script error.', 'first arg');
|
||||
assert_equals(b, '', 'second arg');
|
||||
assert_equals(c, 0, 'third arg');
|
||||
});
|
||||
function col_check() {
|
||||
assert_equals(col_value, 0, 'fourth arg');
|
||||
t_col.done();
|
||||
}
|
||||
var script = document.createElement('script');
|
||||
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/undefined-variable-in-setInterval.js');
|
||||
document.body.appendChild(script);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,32 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - runtime error in cross-origin setTimeout</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(a, 'Script error.', 'first arg');
|
||||
assert_equals(b, '', 'second arg');
|
||||
assert_equals(c, 0, 'third arg');
|
||||
});
|
||||
function col_check() {
|
||||
assert_equals(col_value, 0, 'fourth arg');
|
||||
t_col.done();
|
||||
}
|
||||
var script = document.createElement('script');
|
||||
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/undefined-variable-in-setTimeout.js');
|
||||
document.body.appendChild(script);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - runtime error in <script src=//www1...></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(a, 'Script error.', 'first arg');
|
||||
assert_equals(b, '', 'second arg');
|
||||
assert_equals(c, 0, 'third arg');
|
||||
});
|
||||
var script = document.createElement('script');
|
||||
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/undefined-variable.js');
|
||||
document.body.appendChild(script);
|
||||
onload = function(){
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(col_value, 0, 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,36 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - runtime error in <script src=data:...></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, 'data:text/javascript,undefined_variable;', 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
</script>
|
||||
<script src="data:text/javascript,undefined_variable;"></script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, number, 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - runtime error in attribute</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, location.href, 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
</script>
|
||||
<p onclick="undefined_variable;"></p>
|
||||
<script>
|
||||
t.step(function(){
|
||||
var ev = document.createEvent('Event');
|
||||
ev.initEvent('click', false, false);
|
||||
document.querySelector('p').dispatchEvent(ev);
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, 'number', 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,25 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>runtime error in <body onerror></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var ran = 0;
|
||||
</script>
|
||||
</head>
|
||||
<body onerror="ran++; undefined_variable_in_onerror;">
|
||||
<div id=log></div>
|
||||
<script>
|
||||
undefined_variable;
|
||||
</script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_equals(ran, 1, 'ran');
|
||||
t.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - runtime error in setInterval</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
var interval;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
clearInterval(interval);
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, location.href, 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
interval = setInterval("undefined_variable;", 10);
|
||||
setTimeout(function(){
|
||||
clearInterval(interval);
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, 'number', 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
}, 20);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,36 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - runtime error in setTimeout</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, location.href, 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
setTimeout("undefined_variable;", 10);
|
||||
setTimeout(function(){
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, 'number', 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
}, 20);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,29 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>runtime error in window.onerror</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var ran = 0;
|
||||
window.onerror = function(){
|
||||
ran++;
|
||||
undefined_variable_in_onerror;
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
undefined_variable;
|
||||
</script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_equals(ran, 1, 'ran');
|
||||
t.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,36 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - runtime error in <script src=...></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, document.querySelector('script[src="support/undefined-variable.js"]').src, 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
</script>
|
||||
<script src="support/undefined-variable.js"></script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, 'number', 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror - runtime error in <script></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var t = async_test();
|
||||
var t_col = async_test(document.title+' (column)');
|
||||
var ran = false;
|
||||
var col_value;
|
||||
window.onerror = t.step_func(function(a, b, c, d){
|
||||
ran = true;
|
||||
col_value = d;
|
||||
assert_equals(typeof a, 'string', 'first arg');
|
||||
assert_equals(b, location.href, 'second arg');
|
||||
assert_equals(typeof c, 'number', 'third arg');
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
undefined_variable;
|
||||
</script>
|
||||
<script>
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(function(){
|
||||
assert_equals(typeof col_value, 'number', 'fourth arg');
|
||||
t_col.done();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,9 @@
|
|||
interval = setInterval('{', 10);
|
||||
setTimeout(function(){
|
||||
clearInterval(interval);
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(col_check);
|
||||
}, 20);
|
|
@ -0,0 +1,8 @@
|
|||
setTimeout('{', 10);
|
||||
setTimeout(function(){
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(col_check);
|
||||
}, 20);
|
|
@ -0,0 +1 @@
|
|||
for (;) {}
|
|
@ -0,0 +1,9 @@
|
|||
interval = setInterval('undefined_variable;', 10);
|
||||
setTimeout(function(){
|
||||
clearInterval(interval);
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(col_check);
|
||||
}, 20);
|
|
@ -0,0 +1,8 @@
|
|||
setTimeout('undefined_variable;', 10);
|
||||
setTimeout(function(){
|
||||
t.step(function(){
|
||||
assert_true(ran, 'ran');
|
||||
t.done();
|
||||
});
|
||||
t_col.step(col_check);
|
||||
}, 20);
|
|
@ -0,0 +1 @@
|
|||
undefined_variable;
|
|
@ -0,0 +1,40 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror: parse errors</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<!--
|
||||
|
||||
In https://html.spec.whatwg.org/multipage/#creating-scripts ,
|
||||
step 3 describes parsing the script, and step 5 says:
|
||||
# Otherwise, report the error using the onerror event handler of
|
||||
# the script's global object. If the error is still not handled
|
||||
# after this, then the error may be reported to the user.
|
||||
which links to
|
||||
https://html.spec.whatwg.org/multipage/#report-the-error ,
|
||||
which describes what to do when onerror is a Function.
|
||||
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var error_count = 0;
|
||||
window.onerror = function(msg, url, lineno) {
|
||||
++error_count;
|
||||
test(function() {assert_equals(url, window.location.href)},
|
||||
"correct url passed to window.onerror");
|
||||
test(function() {assert_equals(lineno, 34)},
|
||||
"correct line number passed to window.onerror");
|
||||
};
|
||||
</script>
|
||||
<script>This script does not parse correctly.</script>
|
||||
<script>
|
||||
test(function() {assert_equals(error_count, 1)},
|
||||
"correct number of calls to window.onerror");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror: runtime scripterrors</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<!--
|
||||
|
||||
https://html.spec.whatwg.org/multipage/#runtime-script-errors
|
||||
says what to do for uncaught runtime script errors, and just below
|
||||
describes what to do when onerror is a Function.
|
||||
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var error_count = 0;
|
||||
window.onerror = function(msg, url, lineno) {
|
||||
++error_count;
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
try {
|
||||
// This error is caught, so it should NOT trigger onerror.
|
||||
throw "foo";
|
||||
} catch (ex) {
|
||||
}
|
||||
// This error is NOT caught, so it should trigger onerror.
|
||||
throw "bar";
|
||||
</script>
|
||||
<script>
|
||||
test(function() {assert_equals(error_count, 1)},
|
||||
"correct number of calls to window.onerror");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,43 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.onerror: runtime scripterrors</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<!--
|
||||
|
||||
https://html.spec.whatwg.org/multipage/#runtime-script-errors
|
||||
says what to do for uncaught runtime script errors, and just below
|
||||
describes what to do when onerror is a Function.
|
||||
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception:true});
|
||||
var error_count = 0;
|
||||
window.onerror = function(msg, url, lineno) {
|
||||
++error_count;
|
||||
test(function() {assert_equals(url, window.location.href)},
|
||||
"correct url passed to window.onerror");
|
||||
test(function() {assert_equals(lineno, 36)},
|
||||
"correct line number passed to window.onerror");
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
try {
|
||||
// This error is caught, so it should NOT trigger onerror.
|
||||
window.nonexistentproperty.oops();
|
||||
} catch (ex) {
|
||||
}
|
||||
// This error is NOT caught, so it should trigger onerror.
|
||||
window.nonexistentproperty.oops();
|
||||
</script>
|
||||
<script>
|
||||
test(function() {assert_equals(error_count, 1)},
|
||||
"correct number of calls to window.onerror");
|
||||
</script>
|
||||
</body>
|
||||
</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>
|
|
@ -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>
|
|
@ -0,0 +1,23 @@
|
|||
<!doctype html>
|
||||
<title>Interaction of setTimeout and WebIDL</title>
|
||||
<link rel="author" title="Ian Hickson" href="mailto:ian@hixie.ch">
|
||||
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-windowtimers-settimeout">
|
||||
<link rel="help" href="https://heycam.github.io/webidl/#es-operations">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test()
|
||||
function finishTest() {
|
||||
assert_equals(log, "ONE TWO ")
|
||||
t.done()
|
||||
}
|
||||
var log = '';
|
||||
function logger(s) { log += s + ' '; }
|
||||
|
||||
setTimeout({ toString: function () {
|
||||
setTimeout("logger('ONE')", 100);
|
||||
return "logger('TWO'); t.step(finishTest)";
|
||||
} }, 100);
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue