Update web-platform-tests to revision e8bfc205e36ad699601212cd50083870bad9a75d

This commit is contained in:
Ms2ger 2016-11-14 11:07:09 +01:00
parent 65dd6d4340
commit ccdb0a3458
1428 changed files with 118036 additions and 9786 deletions

View file

@ -0,0 +1,22 @@
<!doctype html>
<meta charset=utf-8>
<title>requestIdleCallback callback exception reported to error handler</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id="log"></div>
<script>
var custom_exception = 'requestIdleCallbackException';
setup({allow_uncaught_exception : true});
async_test(function (t) {
assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
addEventListener("error",function(e) {
t.step(function() {
assert_equals(e.error.message, custom_exception);
t.done();
})
});
window.requestIdleCallback(function () {
throw new Error(custom_exception);
});
}, "requestIdleCallback callback exceptions are reported to error handler");
</script>

View file

@ -0,0 +1,17 @@
<!doctype html>
<meta charset=utf-8>
<title></title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id="log"></div>
<iframe style="display:none" id="frame"></iframe>
<script>
async_test(function (t) {
let frame = document.getElementById("frame");
frame.contentWindow.test = function() {
frame.contentWindow.requestIdleCallback(t.step_func_done());
}
frame.contentWindow.test();
});
</script>

View file

@ -0,0 +1,12 @@
<!doctype html>
<meta charset=utf-8>
<title>requestIdleCallback callback must be called eventually</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id="log"></div>
<script>
async_test(function (t) {
assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
window.requestIdleCallback(t.step_func_done());
}, "requestIdleCallback callback is invoked at least once before the timeout");
</script>

View file

@ -0,0 +1,41 @@
<!doctype html>
<meta charset=utf-8>
<title>multiple calls to requestIdleCallback</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id="log"></div>
<script>
async_test(function (t) {
assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
var counter = 0;
function f(c) {
assert_equals(counter, c);
if (counter === 99) {
t.done();
}
++counter;
}
for (var i = 0; i < 100; ++i) {
let j = i;
window.requestIdleCallback(t.step_func(function () { f(j) }));
}
}, "requestIdleCallback callbacks should be invoked in order (called iteratively)");
async_test(function (t) {
assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
var counter = 0;
function f(c) {
assert_equals(counter, c);
if (counter === 99) {
t.done();
}
++counter;
window.requestIdleCallback(t.step_func(function () { f(c + 1) }));
}
window.requestIdleCallback(t.step_func(function () { f(0) }));
}, "requestIdleCallback callbacks should be invoked in order (called recursively)");
</script>

View file

@ -0,0 +1,28 @@
<!doctype html>
<meta charset=utf-8>
<title>requestIdleCallback timeout callback must be called with didTimeout equal to true</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id="log"></div>
<script>
async_test(function (t) {
assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
var counter = 0;
function g(deadline) {
assert_true(deadline.didTimeout)
t.done();
}
function f(deadline) {
assert_false(deadline.didTimeout);
window.requestIdleCallback(t.step_func(g), {timeout:300});
var d = Date.now() + 500;
while (Date.now() < d) {
}
}
window.requestIdleCallback(t.step_func(f));
}, "requestIdleCallback callback should time out");
</script>

View file

@ -0,0 +1,26 @@
<!doctype html>
<meta charset=utf-8>
<title>cancelling idle requests</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id="log"></div>
<script>
test(function (t) {
window.cancelIdleCallback(42);
assert_true(true);
}, "cancelIdleCallback does nothing if there is no callback with the given handle");
async_test(function (t) {
assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
var neverCalled = true;
var handle = window.requestIdleCallback(function () {
neverCalled = false;
});
window.cancelIdleCallback(handle);
t.step_timeout(function() {
assert_true(neverCalled);
t.done();
}, 2000);
}, "A cancelled callback is never invoked");
</script>

View file

@ -0,0 +1,34 @@
<!doctype html>
<meta charset=utf-8>
<title>idlharness test</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
<pre id='untested_idl' style='display:none'>
[PrimaryGlobal]
interface Window {
};
</pre>
<pre id='idl'>
partial interface Window {
unsigned long requestIdleCallback(IdleRequestCallback callback,
optional IdleRequestOptions options);
void cancelIdleCallback(unsigned long handle);
};
dictionary IdleRequestOptions {
unsigned long timeout;
};
callback IdleRequestCallback = void (IdleDeadline deadline);
</pre>
<script>
var idl_array = new IdlArray();
idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
idl_array.add_idls(document.getElementById("idl").textContent);
idl_array.add_objects({Window: ["window"]});
idl_array.test();
</script>

View file

@ -21,4 +21,14 @@ handlers.forEach(function(handler) {
}, handler);
});
handlers.forEach(function(handler) {
document.body['on' + handler] = null;
});
handlers.forEach(function(handler) {
test(function() {
assert_equals(document.body['on' + handler], null);
assert_equals(window['on' + handler], null);
}, handler + " removal");
});
</script>

View file

@ -0,0 +1,96 @@
<!DOCTYPE html>
<title>MessageEvent constructor</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
<script>
test(function() {
var ev = new MessageEvent("test")
assert_equals(ev.type, "test", "type attribute")
assert_equals(ev.target, null, "target attribute")
assert_equals(ev.currentTarget, null, "currentTarget attribute")
assert_equals(ev.eventPhase, Event.NONE, "eventPhase attribute")
assert_equals(ev.bubbles, false, "bubbles attribute")
assert_equals(ev.cancelable, false, "cancelable attribute")
assert_equals(ev.defaultPrevented, false, "defaultPrevented attribute")
assert_equals(ev.isTrusted, false, "isTrusted attribute")
assert_true(ev.timeStamp > 0, "timeStamp attribute")
assert_true("initMessageEvent" in ev, "initMessageEvent operation")
assert_equals(ev.data, null, "data attribute")
assert_equals(ev.origin, "", "origin attribute")
assert_equals(ev.lastEventId, "", "lastEventId attribute")
assert_equals(ev.source, null, "source attribute")
assert_array_equals(ev.ports, [], "ports attribute")
}, "Default event values")
test(function() {
var channel = new MessageChannel()
var ev = new MessageEvent("test", { data: "testData", origin: "testOrigin", lastEventId: "testId", source: window, ports: [channel.port1] })
assert_equals(ev.type, "test", "type attribute")
assert_equals(ev.data, "testData", "data attribute")
assert_equals(ev.origin, "testOrigin", "origin attribute")
assert_equals(ev.lastEventId, "testId", "lastEventId attribute")
assert_equals(ev.source, window, "source attribute")
assert_array_equals(ev.ports, [channel.port1], "ports attribute")
}, "MessageEventInit dictionary")
test(function() {
assert_throws(new TypeError(), function() {
new MessageEvent("test", { ports: null })
})
}, "Passing null for ports member")
test(function() {
var ev = new MessageEvent("test", { ports: [] })
assert_true(Array.isArray(ev.ports), "Array.isArray() should return true")
assert_true(Object.isFrozen(ev.ports), "Object.isFrozen() should return true")
assert_true(ev.ports === ev.ports, "ev.ports should return the same object")
}, "ports attribute should be a FrozenArray")
test(function() {
var ev = document.createEvent("messageevent");
var channel = new MessageChannel()
ev.initMessageEvent("test", true, false, "testData", "testOrigin", "testId", window, [channel.port1])
assert_equals(ev.type, "test", "type attribute")
assert_equals(ev.bubbles, true, "bubbles attribute")
assert_equals(ev.cancelable, false, "bubbles attribute")
assert_equals(ev.data, "testData", "data attribute")
assert_equals(ev.origin, "testOrigin", "origin attribute")
assert_equals(ev.lastEventId, "testId", "lastEventId attribute")
assert_equals(ev.source, window, "source attribute")
assert_array_equals(ev.ports, [channel.port1], "ports attribute")
}, "initMessageEvent operation")
test(function() {
var ev = document.createEvent("messageevent")
assert_throws(new TypeError(), function() {
ev.initMessageEvent("test", true, false, "testData", "testOrigin", "testId", window, null)
})
}, "Passing null for ports parameter to initMessageEvent")
test(function() {
var ev = document.createEvent("messageevent")
assert_equals(MessageEvent.prototype.initMessageEvent.length, 8, "MessageEvent.prototype.initMessageEvent.length should be 8")
assert_throws(new TypeError(), function() {
ev.initMessageEvent("test", true, false, "testData", "testOrigin", "testId", window)
}, "Calling initMessageEvent with only 7 parameters should throw a TypeError")
}, "All parameters to initMessageEvent should be mandatory")
promise_test(function(t) {
var worker_url = "/service-workers/service-worker/resources/empty-worker.js";
var scope = "/service-workers/service-worker/resources/";
var registration;
return service_worker_unregister_and_register(t, worker_url, scope)
.then(function(r) {
registration = r;
return wait_for_state(t, r.installing, "activated");
})
.then(function() {
var ev = new MessageEvent("test", { source: registration.active });
assert_equals(ev.source, registration.active, "source attribute should return the ServiceWorker");
service_worker_unregister(t, scope);
});
}, "Passing ServiceWorker for source member");
</script>

View file

@ -1,11 +1,19 @@
function run_test() {
var compatibilityMode;
if (navigator.userAgent.includes("Chrome")) {
compatibilityMode = "Chrome";
} else if (navigator.userAgent.includes("WebKit")) {
compatibilityMode = "WebKit";
} else {
compatibilityMode = "Gecko";
}
test(function() {
assert_equals(navigator.appCodeName, "Mozilla");
}, "appCodeName");
test(function() {
assert_equals(typeof navigator.appName, "string",
"navigator.appName should be a string");
assert_equals(navigator.appName, "Netscape");
}, "appName");
test(function() {
@ -23,31 +31,22 @@ function run_test() {
}, "product");
test(function() {
// See https://www.w3.org/Bugs/Public/show_bug.cgi?id=22555
if ("window" in self) {
// If you identify as WebKit, taintEnabled should not exist.
if (navigator.userAgent.indexOf("WebKit") != -1) {
assert_false("taintEnabled" in navigator);
}
// Otherwise it should exist and return false.
else {
assert_false(navigator.taintEnabled());
if (compatibilityMode == "Gecko") {
assert_equals(navigator.productSub, "20100101");
} else {
assert_equals(navigator.productSub, "20030107");
}
} else {
// taintEnabled should not exist in workers.
assert_false("taintEnabled" in navigator);
assert_false("productSub" in navigator);
}
}, "taintEnabled");
}, "productSub");
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() {
@ -60,4 +59,48 @@ function run_test() {
"filter_name=User-Agent");
request.send();
}, "userAgent value");
test(function() {
if ("window" in self) {
if (compatibilityMode == "Chrome") {
assert_equals(navigator.vendor, "Google Inc.");
} else if (compatibilityMode == "WebKit") {
assert_equals(navigator.vendor, "Apple Computer, Inc.");
} else {
assert_equals(navigator.vendor, "");
}
} else {
assert_false("vendor" in navigator);
}
}, "vendor");
test(function() {
if ("window" in self) {
assert_equals(navigator.vendorSub, "");
} else {
assert_false("vendorSub" in navigator);
}
}, "vendorSub");
// "If the navigator compatibility mode is Gecko, then the user agent must
// also support the following partial interface" (taintEnabled() and oscpu)
// See https://www.w3.org/Bugs/Public/show_bug.cgi?id=22555 and
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=27820
test(function() {
if ("window" in self && compatibilityMode == "Gecko") {
assert_false(navigator.taintEnabled());
} else {
assert_false("taintEnabled" in navigator);
}
}, "taintEnabled");
test(function() {
if ("window" in self && compatibilityMode == "Gecko") {
assert_equals(typeof navigator.oscpu, "string",
"navigator.oscpu should be a string");
} else {
assert_false("oscpu" in navigator);
}
}, "oscpu");
}