Update web-platform-tests to revision 7a767a52741f628430ffbbed46e7f3df68ba3534

Fixes #15648.
This commit is contained in:
Ms2ger 2017-02-20 11:44:42 +01:00
parent a1e4c547f0
commit 4fadf9b0b6
1184 changed files with 22551 additions and 9856 deletions

View file

@ -0,0 +1,311 @@
<!doctype html>
<meta charset=utf-8>
<title></title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
var log = [];
function clearLog() {
log = [];
}
function addLogEntry(name, args) {
log.push([ name, ...args ]);
}
var loggingHandler = {
};
setup(function() {
for (let prop of Object.getOwnPropertyNames(Reflect)) {
loggingHandler[prop] = function(...args) {
addLogEntry(prop, args);
return Reflect[prop](...args);
}
}
});
test(function() {
var h = new Headers();
assert_equals([...h].length, 0);
}, "Passing nothing to Headers constructor");
test(function() {
var h = new Headers(undefined);
assert_equals([...h].length, 0);
}, "Passing undefined to Headers constructor");
test(function() {
assert_throws(new TypeError, function() {
var h = new Headers(null);
});
}, "Passing null to Headers constructor");
test(function() {
this.add_cleanup(clearLog);
var record = { a: "b" };
var proxy = new Proxy(record, loggingHandler);
var h = new Headers(proxy);
assert_equals(log.length, 4);
// The first thing is the [[Get]] of Symbol.iterator to figure out whether
// we're a sequence, during overload resolution.
assert_array_equals(log[0], ["get", record, Symbol.iterator, proxy]);
// Then we have the [[OwnPropertyKeys]] from
// https://heycam.github.io/webidl/#es-to-record step 4.
assert_array_equals(log[1], ["ownKeys", record]);
// Then the [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[2], ["getOwnPropertyDescriptor", record, "a"]);
// Then the [[Get]] from step 5.2.
assert_array_equals(log[3], ["get", record, "a", proxy]);
// Check the results.
assert_equals([...h].length, 1);
assert_array_equals([...h.keys()], ["a"]);
assert_true(h.has("a"));
assert_equals(h.get("a"), "b");
}, "Basic operation with one property");
test(function() {
this.add_cleanup(clearLog);
var recordProto = { c: "d" };
var record = Object.create(recordProto, { a: { value: "b", enumerable: true } });
var proxy = new Proxy(record, loggingHandler);
var h = new Headers(proxy);
assert_equals(log.length, 4);
// The first thing is the [[Get]] of Symbol.iterator to figure out whether
// we're a sequence, during overload resolution.
assert_array_equals(log[0], ["get", record, Symbol.iterator, proxy]);
// Then we have the [[OwnPropertyKeys]] from
// https://heycam.github.io/webidl/#es-to-record step 4.
assert_array_equals(log[1], ["ownKeys", record]);
// Then the [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[2], ["getOwnPropertyDescriptor", record, "a"]);
// Then the [[Get]] from step 5.2.
assert_array_equals(log[3], ["get", record, "a", proxy]);
// Check the results.
assert_equals([...h].length, 1);
assert_array_equals([...h.keys()], ["a"]);
assert_true(h.has("a"));
assert_equals(h.get("a"), "b");
}, "Basic operation with one property and a proto");
test(function() {
this.add_cleanup(clearLog);
var record = { a: "b", c: "d" };
var proxy = new Proxy(record, loggingHandler);
var h = new Headers(proxy);
assert_equals(log.length, 6);
// The first thing is the [[Get]] of Symbol.iterator to figure out whether
// we're a sequence, during overload resolution.
assert_array_equals(log[0], ["get", record, Symbol.iterator, proxy]);
// Then we have the [[OwnPropertyKeys]] from
// https://heycam.github.io/webidl/#es-to-record step 4.
assert_array_equals(log[1], ["ownKeys", record]);
// Then the [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[2], ["getOwnPropertyDescriptor", record, "a"]);
// Then the [[Get]] from step 5.2.
assert_array_equals(log[3], ["get", record, "a", proxy]);
// Then the second [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[4], ["getOwnPropertyDescriptor", record, "c"]);
// Then the second [[Get]] from step 5.2.
assert_array_equals(log[5], ["get", record, "c", proxy]);
// Check the results.
assert_equals([...h].length, 2);
assert_array_equals([...h.keys()], ["a", "c"]);
assert_true(h.has("a"));
assert_equals(h.get("a"), "b");
assert_true(h.has("c"));
assert_equals(h.get("c"), "d");
}, "Correct operation ordering with two properties");
test(function() {
this.add_cleanup(clearLog);
var record = { a: "b", "\uFFFF": "d" };
var proxy = new Proxy(record, loggingHandler);
assert_throws(new TypeError, function() {
var h = new Headers(proxy);
});
assert_equals(log.length, 5);
// The first thing is the [[Get]] of Symbol.iterator to figure out whether
// we're a sequence, during overload resolution.
assert_array_equals(log[0], ["get", record, Symbol.iterator, proxy]);
// Then we have the [[OwnPropertyKeys]] from
// https://heycam.github.io/webidl/#es-to-record step 4.
assert_array_equals(log[1], ["ownKeys", record]);
// Then the [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[2], ["getOwnPropertyDescriptor", record, "a"]);
// Then the [[Get]] from step 5.2.
assert_array_equals(log[3], ["get", record, "a", proxy]);
// Then the second [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[4], ["getOwnPropertyDescriptor", record, "\uFFFF"]);
// The second [[Get]] never happens, because we convert the invalid name to a
// ByteString first and throw.
}, "Correct operation ordering with two properties one of which has an invalid name");
test(function() {
this.add_cleanup(clearLog);
var record = { a: "\uFFFF", c: "d" }
var proxy = new Proxy(record, loggingHandler);
assert_throws(new TypeError, function() {
var h = new Headers(proxy);
});
assert_equals(log.length, 4);
// The first thing is the [[Get]] of Symbol.iterator to figure out whether
// we're a sequence, during overload resolution.
assert_array_equals(log[0], ["get", record, Symbol.iterator, proxy]);
// Then we have the [[OwnPropertyKeys]] from
// https://heycam.github.io/webidl/#es-to-record step 4.
assert_array_equals(log[1], ["ownKeys", record]);
// Then the [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[2], ["getOwnPropertyDescriptor", record, "a"]);
// Then the [[Get]] from step 5.2.
assert_array_equals(log[3], ["get", record, "a", proxy]);
// Nothing else after this, because converting the result of that [[Get]] to a
// ByteString throws.
}, "Correct operation ordering with two properties one of which has an invalid value");
test(function() {
this.add_cleanup(clearLog);
var record = {};
Object.defineProperty(record, "a", { value: "b", enumerable: false });
Object.defineProperty(record, "c", { value: "d", enumerable: true });
Object.defineProperty(record, "e", { value: "f", enumerable: false });
var proxy = new Proxy(record, loggingHandler);
var h = new Headers(proxy);
assert_equals(log.length, 6);
// The first thing is the [[Get]] of Symbol.iterator to figure out whether
// we're a sequence, during overload resolution.
assert_array_equals(log[0], ["get", record, Symbol.iterator, proxy]);
// Then we have the [[OwnPropertyKeys]] from
// https://heycam.github.io/webidl/#es-to-record step 4.
assert_array_equals(log[1], ["ownKeys", record]);
// Then the [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[2], ["getOwnPropertyDescriptor", record, "a"]);
// No [[Get]] because not enumerable
// Then the second [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[3], ["getOwnPropertyDescriptor", record, "c"]);
// Then the [[Get]] from step 5.2.
assert_array_equals(log[4], ["get", record, "c", proxy]);
// Then the third [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[5], ["getOwnPropertyDescriptor", record, "e"]);
// No [[Get]] because not enumerable
// Check the results.
assert_equals([...h].length, 1);
assert_array_equals([...h.keys()], ["c"]);
assert_true(h.has("c"));
assert_equals(h.get("c"), "d");
}, "Correct operation ordering with non-enumerable properties");
test(function() {
this.add_cleanup(clearLog);
var record = {a: "b", c: "d", e: "f"};
var lyingHandler = {
getOwnPropertyDescriptor: function(target, name) {
if (name == "a" || name == "e") {
return undefined;
}
return Reflect.getOwnPropertyDescriptor(target, name);
}
};
var lyingProxy = new Proxy(record, lyingHandler);
var proxy = new Proxy(lyingProxy, loggingHandler);
var h = new Headers(proxy);
assert_equals(log.length, 6);
// The first thing is the [[Get]] of Symbol.iterator to figure out whether
// we're a sequence, during overload resolution.
assert_array_equals(log[0], ["get", lyingProxy, Symbol.iterator, proxy]);
// Then we have the [[OwnPropertyKeys]] from
// https://heycam.github.io/webidl/#es-to-record step 4.
assert_array_equals(log[1], ["ownKeys", lyingProxy]);
// Then the [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[2], ["getOwnPropertyDescriptor", lyingProxy, "a"]);
// No [[Get]] because no descriptor
// Then the second [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[3], ["getOwnPropertyDescriptor", lyingProxy, "c"]);
// Then the [[Get]] from step 5.2.
assert_array_equals(log[4], ["get", lyingProxy, "c", proxy]);
// Then the third [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[5], ["getOwnPropertyDescriptor", lyingProxy, "e"]);
// No [[Get]] because no descriptor
// Check the results.
assert_equals([...h].length, 1);
assert_array_equals([...h.keys()], ["c"]);
assert_true(h.has("c"));
assert_equals(h.get("c"), "d");
}, "Correct operation ordering with undefined descriptors");
test(function() {
this.add_cleanup(clearLog);
var record = {a: "b", c: "d"};
var lyingHandler = {
ownKeys: function() {
return [ "a", "c", "a", "c" ];
},
getCalls: 0,
gotCOnce: false,
get: function(target, name, receiver) {
if (name == "c") {
this.gotCOnce = true;
}
if (typeof name == "string") {
return ++this.getCalls;
}
return Reflect.get(target, name, receiver);
},
getOwnPropertyDescriptor: function(target, name) {
var desc = Reflect.getOwnPropertyDescriptor(target, name);
if (name == "c" && this.gotCOnce) {
desc.enumerable = false;
}
return desc;
}
};
var lyingProxy = new Proxy(record, lyingHandler);
var proxy = new Proxy(lyingProxy, loggingHandler);
var h = new Headers(proxy);
assert_equals(log.length, 9);
// The first thing is the [[Get]] of Symbol.iterator to figure out whether
// we're a sequence, during overload resolution.
assert_array_equals(log[0], ["get", lyingProxy, Symbol.iterator, proxy]);
// Then we have the [[OwnPropertyKeys]] from
// https://heycam.github.io/webidl/#es-to-record step 4.
assert_array_equals(log[1], ["ownKeys", lyingProxy]);
// Then the [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[2], ["getOwnPropertyDescriptor", lyingProxy, "a"]);
// Then the [[Get]] from step 5.2.
assert_array_equals(log[3], ["get", lyingProxy, "a", proxy]);
// Then the second [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[4], ["getOwnPropertyDescriptor", lyingProxy, "c"]);
// Then the second [[Get]] from step 5.2.
assert_array_equals(log[5], ["get", lyingProxy, "c", proxy]);
// Then the third [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[6], ["getOwnPropertyDescriptor", lyingProxy, "a"]);
// Then the third [[Get]] from step 5.2.
assert_array_equals(log[7], ["get", lyingProxy, "a", proxy]);
// Then the fourth [[GetOwnProperty]] from step 5.1.
assert_array_equals(log[8], ["getOwnPropertyDescriptor", lyingProxy, "c"]);
// No [[Get]] because not enumerable.
// Check the results.
assert_equals([...h].length, 2);
assert_array_equals([...h.keys()], ["a", "c"]);
assert_true(h.has("a"));
assert_equals(h.get("a"), "3");
assert_true(h.has("c"));
assert_equals(h.get("c"), "2");
}, "Correct operation ordering with repeated keys");
// Need to add symbol tests, but those are pending
// https://github.com/heycam/webidl/issues/294 being resolved.
</script>

View file

@ -14,7 +14,7 @@
<script>
var tests = [
{
name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
name: 'RequestCache "default" mode with an If-Modified-Since header (following a request without additional headers) is treated similarly to "no-store"',
state: "stale",
request_cache: ["default", "default"],
request_headers: [{}, {"If-Modified-Since": now.toGMTString()}],
@ -22,7 +22,7 @@
expected_no_cache_headers: [false, true],
},
{
name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
name: 'RequestCache "default" mode with an If-Modified-Since header (following a request without additional headers) is treated similarly to "no-store"',
state: "fresh",
request_cache: ["default", "default"],
request_headers: [{}, {"If-Modified-Since": now.toGMTString()}],
@ -46,7 +46,7 @@
expected_no_cache_headers: [true, false],
},
{
name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
name: 'RequestCache "default" mode with an If-None-Match header (following a request without additional headers) is treated similarly to "no-store"',
state: "stale",
request_cache: ["default", "default"],
request_headers: [{}, {"If-None-Match": '"foo"'}],
@ -54,7 +54,7 @@
expected_no_cache_headers: [false, true],
},
{
name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
name: 'RequestCache "default" mode with an If-None-Match header (following a request without additional headers) is treated similarly to "no-store"',
state: "fresh",
request_cache: ["default", "default"],
request_headers: [{}, {"If-None-Match": '"foo"'}],
@ -78,7 +78,7 @@
expected_no_cache_headers: [true, false],
},
{
name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
name: 'RequestCache "default" mode with an If-Unmodified-Since header (following a request without additional headers) is treated similarly to "no-store"',
state: "stale",
request_cache: ["default", "default"],
request_headers: [{}, {"If-Unmodified-Since": now.toGMTString()}],
@ -86,7 +86,7 @@
expected_no_cache_headers: [false, true],
},
{
name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
name: 'RequestCache "default" mode with an If-Unmodified-Since header (following a request without additional headers) is treated similarly to "no-store"',
state: "fresh",
request_cache: ["default", "default"],
request_headers: [{}, {"If-Unmodified-Since": now.toGMTString()}],
@ -110,7 +110,7 @@
expected_no_cache_headers: [true, false],
},
{
name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
name: 'RequestCache "default" mode with an If-Match header (following a request without additional headers) is treated similarly to "no-store"',
state: "stale",
request_cache: ["default", "default"],
request_headers: [{}, {"If-Match": '"foo"'}],
@ -118,7 +118,7 @@
expected_no_cache_headers: [false, true],
},
{
name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
name: 'RequestCache "default" mode with an If-Match header (following a request without additional headers) is treated similarly to "no-store"',
state: "fresh",
request_cache: ["default", "default"],
request_headers: [{}, {"If-Match": '"foo"'}],
@ -142,7 +142,7 @@
expected_no_cache_headers: [true, false],
},
{
name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
name: 'RequestCache "default" mode with an If-Range header (following a request without additional headers) is treated similarly to "no-store"',
state: "stale",
request_cache: ["default", "default"],
request_headers: [{}, {"If-Range": '"foo"'}],
@ -150,7 +150,7 @@
expected_no_cache_headers: [false, true],
},
{
name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
name: 'RequestCache "default" mode with an If-Range header (following a request without additional headers) is treated similarly to "no-store"',
state: "fresh",
request_cache: ["default", "default"],
request_headers: [{}, {"If-Range": '"foo"'}],