Update web-platform-tests to revision 81962ac8802223d038b188b6f9cb88a0a9c5beee

This commit is contained in:
WPT Sync Bot 2018-05-18 22:02:29 -04:00
parent fe1a057bd1
commit 24183668c4
1960 changed files with 29853 additions and 10555 deletions

View file

@ -10,7 +10,7 @@ policies and contribution forms [3].
[3] http://www.w3.org/2004/10/27-testcases
*/
/* Documentation: http://web-platform-tests.org/writing-tests/testharness-api.html
/* Documentation: https://web-platform-tests.org/writing-tests/testharness-api.html
* (../docs/_writing-tests/testharness-api.md) */
(function (global_scope)
@ -451,6 +451,50 @@ policies and contribution forms [3].
}
};
/*
* JavaScript shells.
*
* This class is used as the test_environment when testharness is running
* inside a JavaScript shell.
*/
function ShellTestEnvironment() {
this.name_counter = 0;
this.all_loaded = false;
this.on_loaded_callback = null;
Promise.resolve().then(function() {
this.all_loaded = true
if (this.on_loaded_callback) {
this.on_loaded_callback();
}
}.bind(this));
this.message_list = [];
this.message_ports = [];
}
ShellTestEnvironment.prototype.next_default_test_name = function() {
var suffix = this.name_counter > 0 ? " " + this.name_counter : "";
this.name_counter++;
return "Untitled" + suffix;
};
ShellTestEnvironment.prototype.on_new_harness_properties = function() {};
ShellTestEnvironment.prototype.on_tests_ready = function() {};
ShellTestEnvironment.prototype.add_on_loaded_callback = function(callback) {
if (this.all_loaded) {
callback();
} else {
this.on_loaded_callback = callback;
}
};
ShellTestEnvironment.prototype.test_timeout = function() {
// Tests running in a shell don't have a default timeout, so behave as
// if settings.explicit_timeout is true.
return null;
};
function create_test_environment() {
if ('document' in global_scope) {
return new WindowTestEnvironment();
@ -472,6 +516,10 @@ policies and contribution forms [3].
return new DedicatedWorkerTestEnvironment();
}
if (!('self' in global_scope)) {
return new ShellTestEnvironment();
}
throw new Error("Unsupported test environment");
}
@ -1610,7 +1658,9 @@ policies and contribution forms [3].
this.phase = this.phases.COMPLETE;
clearTimeout(this.timeout_id);
if (global_scope.clearTimeout) {
clearTimeout(this.timeout_id);
}
tests.result(this);
this.cleanup();
};
@ -1730,6 +1780,12 @@ policies and contribution forms [3].
}
};
if (self.Promise) {
this.done = new Promise(function(resolve) {
this_obj.doneResolve = resolve;
});
}
this.message_target.addEventListener("message", this.message_handler);
}
@ -1779,6 +1835,10 @@ policies and contribution forms [3].
this.running = false;
this.remote = null;
this.message_target = null;
if (this.doneResolve) {
this.doneResolve();
}
if (tests.all_done()) {
tests.complete();
}
@ -1925,12 +1985,14 @@ policies and contribution forms [3].
};
Tests.prototype.set_timeout = function() {
var this_obj = this;
clearTimeout(this.timeout_id);
if (this.timeout_length !== null) {
this.timeout_id = setTimeout(function() {
this_obj.timeout();
}, this.timeout_length);
if (global_scope.clearTimeout) {
var this_obj = this;
clearTimeout(this.timeout_id);
if (this.timeout_length !== null) {
this.timeout_id = setTimeout(function() {
this_obj.timeout();
}, this.timeout_length);
}
}
};
@ -2135,11 +2197,13 @@ policies and contribution forms [3].
return;
}
this.pending_remotes.push(this.create_remote_worker(worker));
var remoteContext = this.create_remote_worker(worker);
this.pending_remotes.push(remoteContext);
return remoteContext.done;
};
function fetch_tests_from_worker(port) {
tests.fetch_tests_from_worker(port);
return tests.fetch_tests_from_worker(port);
}
expose(fetch_tests_from_worker, 'fetch_tests_from_worker');
@ -2910,36 +2974,38 @@ policies and contribution forms [3].
var tests = new Tests();
var error_handler = function(e) {
if (tests.tests.length === 0 && !tests.allow_uncaught_exception) {
tests.set_file_is_test();
}
var stack;
if (e.error && e.error.stack) {
stack = e.error.stack;
} else {
stack = e.filename + ":" + e.lineno + ":" + e.colno;
}
if (tests.file_is_test) {
var test = tests.tests[0];
if (test.phase >= test.phases.HAS_RESULT) {
return;
if (global_scope.addEventListener) {
var error_handler = function(e) {
if (tests.tests.length === 0 && !tests.allow_uncaught_exception) {
tests.set_file_is_test();
}
test.set_status(test.FAIL, e.message, stack);
test.phase = test.phases.HAS_RESULT;
test.done();
} else if (!tests.allow_uncaught_exception) {
tests.status.status = tests.status.ERROR;
tests.status.message = e.message;
tests.status.stack = stack;
}
done();
};
addEventListener("error", error_handler, false);
addEventListener("unhandledrejection", function(e){ error_handler(e.reason); }, false);
var stack;
if (e.error && e.error.stack) {
stack = e.error.stack;
} else {
stack = e.filename + ":" + e.lineno + ":" + e.colno;
}
if (tests.file_is_test) {
var test = tests.tests[0];
if (test.phase >= test.phases.HAS_RESULT) {
return;
}
test.set_status(test.FAIL, e.message, stack);
test.phase = test.phases.HAS_RESULT;
test.done();
} else if (!tests.allow_uncaught_exception) {
tests.status.status = tests.status.ERROR;
tests.status.message = e.message;
tests.status.stack = stack;
}
done();
};
addEventListener("error", error_handler, false);
addEventListener("unhandledrejection", function(e){ error_handler(e.reason); }, false);
}
test_environment.on_tests_ready();