Bug 1388728 - Improve module loader mochitests and re-enable failing WPT tests r=bkelly

This commit is contained in:
Jon Coppeard 2017-08-22 10:43:27 +01:00
Родитель 57cc56cf0b
Коммит 4ccabf8cae
23 изменённых файлов: 72 добавлений и 106 удалений

Просмотреть файл

@ -4,20 +4,27 @@
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
var wasRun = false;
var hadSyntaxError = false;
var errorCount = 0;
var syntaxErrorCount = 0;
var eventCount = 0;
SimpleTest.waitForExplicitFinish();
window.onerror = handleError;
function handleError(message, url, line, column, error) {
hadSyntaxError = error instanceof SyntaxError;
errorCount++;
if (error instanceof SyntaxError) {
syntaxErrorCount++;
}
}
function testError() {
ok(!wasRun, 'Check script was not run');
ok(hadSyntaxError, 'Check that a SyntaxError was thrown');
ok(errorCount == 1, 'Check that an error was reported');
ok(syntaxErrorCount == 1, 'Check that a syntax error was reported');
ok(eventCount == 0, 'Check that no error event was fired');
SimpleTest.finish();
}
</script>
<script type="module" src="module_badSyntax.js"></script>
<script type="module" src="module_badSyntax.js" onerror="eventCount++"></script>
<body onload='testError()'></body>

Просмотреть файл

@ -4,20 +4,27 @@
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
var wasRun = false;
var hadSyntaxError = false;
var errorCount = 0;
var syntaxErrorCount = 0;
var eventCount = 0;
SimpleTest.waitForExplicitFinish();
window.onerror = handleError;
function handleError(message, url, line, column, error) {
hadSyntaxError = error instanceof SyntaxError;
errorCount++;
if (error instanceof SyntaxError) {
syntaxErrorCount++;
}
}
function testError() {
ok(!wasRun, 'Check script was not run');
ok(hadSyntaxError, 'Check that a SyntaxError was thrown');
ok(errorCount == 1, 'Check that an error was reported');
ok(syntaxErrorCount == 1, 'Check that a syntax error was reported');
ok(eventCount == 0, 'Check that no error event was fired');
SimpleTest.finish();
}
</script>
<script type="module" src="module_badSyntax.js" async></script>
<script type="module" src="module_badSyntax.js" async onerror="eventCount++"></script>
<body onload='testError()'></body>

Просмотреть файл

@ -4,22 +4,29 @@
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
var wasRun = false;
var hadSyntaxError = false;
var errorCount = 0;
var syntaxErrorCount = 0;
var eventCount = 0;
SimpleTest.waitForExplicitFinish();
window.onerror = handleError;
function handleError(message, url, line, column, error) {
hadSyntaxError = error instanceof SyntaxError;
errorCount++;
if (error instanceof SyntaxError) {
syntaxErrorCount++;
}
}
function testError() {
ok(!wasRun, 'Check script was not run');
ok(hadSyntaxError, 'Check that a SyntaxError was thrown');
ok(errorCount == 1, 'Check that an error was reported');
ok(syntaxErrorCount == 1, 'Check that a syntax error was reported');
ok(eventCount == 0, 'Check that no error event was fired');
SimpleTest.finish();
}
</script>
<script type="module">
<script type="module" onerror="eventCount++">
// Module with a syntax error.
some invalid js syntax;
wasRun = true;

Просмотреть файл

@ -4,22 +4,29 @@
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
var wasRun = false;
var hadSyntaxError = false;
var errorCount = 0;
var syntaxErrorCount = 0;
var eventCount = 0;
SimpleTest.waitForExplicitFinish();
window.onerror = handleError;
function handleError(message, url, line, column, error) {
hadSyntaxError = error instanceof SyntaxError;
errorCount++;
if (error instanceof SyntaxError) {
syntaxErrorCount++;
}
}
function testError() {
ok(!wasRun, 'Check script was not run');
ok(hadSyntaxError, 'Check that a SyntaxError was thrown');
ok(errorCount == 1, 'Check that an error was reported');
ok(syntaxErrorCount == 1, 'Check that a syntax error was reported');
ok(eventCount == 0, 'Check that no error event was fired');
SimpleTest.finish();
}
</script>
<script type="module" async>
<script type="module" async onerror="eventCount++">
// Module with a syntax error.
some invalid js syntax;
wasRun = true;

Просмотреть файл

@ -594465,7 +594465,7 @@
"support"
],
"html/semantics/scripting-1/the-script-element/module/errorhandling.html": [
"ffd411f153c55abf313fba5ab349b6a0cc50ba0f",
"10ccf68924459d54784ebc9cfdcdad21cb20811e",
"testharness"
],
"html/semantics/scripting-1/the-script-element/module/evaluation-error-1.html": [

Просмотреть файл

@ -1,5 +0,0 @@
[compilation-error-1.html]
type: testharness
[Test that syntax errors lead to SyntaxError events on window, and that exceptions are remembered.]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[compilation-error-2.html]
type: testharness
[Test that syntax errors lead to SyntaxError events on window, and that exceptions are remembered.]
expected: FAIL

Просмотреть файл

@ -1,14 +1,4 @@
[crossorigin.html]
type: testharness
[Root module, Error in CORS-different-origin script]
expected: FAIL
[Root module, Error in CORS-same-origin script]
expected: FAIL
[Imported module, Error in CORS-different-origin script]
expected: FAIL
[Imported module, Error in CORS-same-origin script]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[errorhandling.html]
type: testharness
[IFrame test: 'iframe_parseError_Dependent']
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[evaluation-error-1.html]
type: testharness
[Test that exceptions during evaluation lead to error events on window, and that exceptions are remembered.\n]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[evaluation-error-2.html]
type: testharness
[Test that ill-founded cyclic dependencies cause ReferenceError during evaluation, which leads to error events on window, and that exceptions are remembered.\n]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[evaluation-error-3.html]
type: testharness
[Test that exceptions during evaluation lead to error events on window, and that exceptions are remembered.\n]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[evaluation-error-4.html]
type: testharness
[Test that exceptions during evaluation lead to error events on window, and that exceptions are remembered.\n]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[instantiation-error-2.html]
type: testharness
[Test that missing exports lead to SyntaxError events on window and load events on script, and that exceptions are remembered]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[instantiation-error-3.html]
type: testharness
[Test that unresolvable cycles lead to SyntaxError events on window and load events on script, and that exceptions are remembered]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[instantiation-error-4.html]
type: testharness
[Test that loading a graph in which a module is already errored results in that module's error.]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[instantiation-error-6.html]
type: testharness
[Test that ambiguous star exports lead to an instantiation error and that the correct module is blamed.]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[instantiation-error-7.html]
type: testharness
[Test that ambiguous star exports lead to an instantiation error, even when discovered through a star export, and that the correct module is blamed.]
expected: FAIL

Просмотреть файл

@ -1,8 +1,5 @@
[slow-cycle.html]
type: testharness
expected:
if debug and not e10s: CRASH
if debug and e10s: CRASH
[Cyclic graph with slow imports]
expected: FAIL

Просмотреть файл

@ -1,5 +0,0 @@
[specifier-error.html]
type: testharness
[Test that invalid module specifier leads to TypeError on window.]
expected: FAIL

Просмотреть файл

@ -928,7 +928,7 @@
"testharness"
],
"html/semantics/scripting-1/the-script-element/reload-failed-module-script.html": [
"5b8cf6809bd8d0797f4172bf9a01f9085c0abbaf",
"7bfcf25ed4e793d00b0b33269bc3401545527420",
"testharness"
],
"html/semantics/scripting-1/the-script-element/support/missing_import.js": [

Просмотреть файл

@ -5,21 +5,37 @@
<script src=/resources/testharnessreport.js></script>
<script>
setup({allow_uncaught_exception: true});
var test = async_test("Reload failed module script")
var test = async_test("Reload failed module script");
var errorCount = 0;
window.addEventListener("error", handleError);
function handleError() {
errorCount++;
if (errorCount == 1) {
reloadModule();
return;
}
test.step(() => assert_equals(errorCount, 2));
test.done();
}
function reloadModule() {
var script = document.createElement("script");
script.onerror = function() {
// An error is expected
test.done();
};
script.onload = function() {
test.step(() => assert_unreached("Should not load"));
test.done();
};
script.onerror = testNoError;
script.type = "module";
script.src = "support/missing_import.js";
script.async = false;
document.documentElement.appendChild(script);
}
function testNoError() {
test.step(() => assert_unreached("No event expect here"));
test.done();
}
</script>
<script type="module" src="support/missing_import.js" onerror="reloadModule()"></script>
<script type="module" src="support/missing_import.js" onerror="testNoError()"></script>

Просмотреть файл

@ -55,7 +55,6 @@
assert_unreached("This script should not have loaded!");
}));
document.body.appendChild(script_wrongMimetype_import);
</script>
</body>
</html>