mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Auto merge of #9764 - servo:wpt-20160226, r=Ms2ger
Update web-platform-tests to revision efa05bfb3b338ef988f3ebf4523198512a248a99 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9764) <!-- Reviewable:end -->
This commit is contained in:
commit
dd2f4f6a11
10 changed files with 445 additions and 5457 deletions
File diff suppressed because it is too large
Load diff
|
@ -1 +1 @@
|
||||||
33f0040496bde88683cfadb4068183f7d08a5f1c
|
26b40afe237f97ebd81d537e8ed1201c7c1e4011
|
|
@ -80,8 +80,12 @@
|
||||||
assert_equals(fd.get('key'), "value1");
|
assert_equals(fd.get('key'), "value1");
|
||||||
}, 'testFormDataSetToFormNull2');
|
}, 'testFormDataSetToFormNull2');
|
||||||
test(function() {
|
test(function() {
|
||||||
assert_object_equals(create_formdata(['key', new Blob(), 'blank.txt']).get('key'),
|
var fd = new FormData();
|
||||||
new File(new Blob(), 'blank.txt'));
|
fd.set('key', new Blob([]), 'blank.txt');
|
||||||
|
var file = fd.get('key');
|
||||||
|
|
||||||
|
assert_true(file instanceof File);
|
||||||
|
assert_equals(file.name, 'blank.txt');
|
||||||
}, 'testFormDataSetEmptyBlob');
|
}, 'testFormDataSetEmptyBlob');
|
||||||
|
|
||||||
function create_formdata() {
|
function create_formdata() {
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
|
|
||||||
<h2>Description</h2>
|
<h2>Description</h2>
|
||||||
<p>
|
<p>
|
||||||
This test validates that all of the BatteryManager attributes exist and are set to correct values, with corresponding events fired, when the charger is plugged in.
|
This test validates that all of the BatteryManager attributes exist and
|
||||||
|
are set to correct values, with corresponding events fired,
|
||||||
|
when the charger is plugged in.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2>Preconditions</h2>
|
<h2>Preconditions</h2>
|
||||||
|
@ -25,12 +27,21 @@
|
||||||
The device is unplugged from the charger before this test is run.
|
The device is unplugged from the charger before this test is run.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
The battery must not be full or reach full capacity during the time the test is run.
|
The battery must not be full or reach full capacity before the time the test is run.
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<div id="note">
|
<div id="note">
|
||||||
|
<ol>
|
||||||
|
<li>
|
||||||
Plug in the charger and wait for all the tests to complete.
|
Plug in the charger and wait for all the tests to complete.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
The tests may take long time since the definition of how
|
||||||
|
often the chargingtimechange, dischargingtimechange, and levelchange
|
||||||
|
events are fired is left to the implementation.
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
|
@ -41,10 +52,21 @@
|
||||||
|
|
||||||
setup({ explicit_timeout: true });
|
setup({ explicit_timeout: true });
|
||||||
|
|
||||||
var onchargingchange_test = async_test('When the device is plugged in and its charging state is updated, must set the charging attribute\'s value to true and fire a chargingchange event.');
|
var onchargingchange_test = async_test(
|
||||||
var onchargingtimechange_test = async_test('When the device is plugged in and its charging time is updated, must set the chargingTime attribute\'s value and fire a chargingtimechange event.');
|
'When the device is plugged in and its charging state is updated, ' +
|
||||||
var ondischargingtimechange_test = async_test('When the device is plugged in and its discharging time is updated, must set the dischargingTime attribute\'s value to Infinity and fire a dischargingtimechange event.');
|
'must set the charging attribute\'s value to true and ' +
|
||||||
var onlevelchange_test = async_test('When the device is plugged in and the battery level is updated, must set the level attribute\'s value and fire a levelchange event.');
|
'fire a chargingchange event.');
|
||||||
|
var onchargingtimechange_test = async_test(
|
||||||
|
'When the device is plugged in and its charging time is updated, ' +
|
||||||
|
'must set the chargingTime attribute\'s value and fire ' +
|
||||||
|
'a chargingtimechange event.');
|
||||||
|
var ondischargingtimechange_test = async_test(
|
||||||
|
'When the device is plugged in and its discharging time is updated, ' +
|
||||||
|
'must set the dischargingTime attribute\'s value to Infinity and ' +
|
||||||
|
'fire a dischargingtimechange event.');
|
||||||
|
var onlevelchange_test = async_test(
|
||||||
|
'When the device is plugged in and the battery level is updated, ' +
|
||||||
|
'must set the level attribute\'s value and fire a levelchange event.');
|
||||||
|
|
||||||
var batterySuccess = function (battery) {
|
var batterySuccess = function (battery) {
|
||||||
battery.onchargingchange = onchargingchange_test.step_func(function () {
|
battery.onchargingchange = onchargingchange_test.step_func(function () {
|
||||||
|
@ -54,13 +76,17 @@
|
||||||
|
|
||||||
var battery_chargingtime = battery.chargingTime;
|
var battery_chargingtime = battery.chargingTime;
|
||||||
battery.onchargingtimechange = onchargingtimechange_test.step_func(function () {
|
battery.onchargingtimechange = onchargingtimechange_test.step_func(function () {
|
||||||
assert_less_than(battery.chargingTime, battery_chargingtime, 'The value of the chargingTime attribute must decrease.');
|
assert_less_than(battery.chargingTime, battery_chargingtime,
|
||||||
|
'The value of the chargingTime attribute must decrease.');
|
||||||
onchargingtimechange_test.done();
|
onchargingtimechange_test.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
battery.ondischargingtimechange = ondischargingtimechange_test.step_func(function () {
|
battery.ondischargingtimechange = ondischargingtimechange_test.step_func(function () {
|
||||||
assert_equals(battery.dischargingTime, Infinity, 'The value of the dischargingTime attribute must be set to Infinity.');
|
if (battery.charging) {
|
||||||
|
assert_equals(battery.dischargingTime, Infinity,
|
||||||
|
'The value of the dischargingTime attribute must be set to Infinity.');
|
||||||
ondischargingtimechange_test.done();
|
ondischargingtimechange_test.done();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
battery.onlevelchange = onlevelchange_test.step_func(function () {
|
battery.onlevelchange = onlevelchange_test.step_func(function () {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Battery Test: battery not full, charger unplugging</title>
|
<title>Battery Test: charger unplugging</title>
|
||||||
<meta name="flags" content="interact">
|
<meta name="flags" content="interact">
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
@ -16,7 +16,9 @@
|
||||||
|
|
||||||
<h2>Description</h2>
|
<h2>Description</h2>
|
||||||
<p>
|
<p>
|
||||||
This test validates that all of the BatteryManager attributes exist and are set to correct values, with corresponding events fired, when the charger is unplugged.
|
This test validates that all of the BatteryManager attributes exist and
|
||||||
|
are set to correct values, with corresponding events fired,
|
||||||
|
when the charger is unplugged.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2>Preconditions</h2>
|
<h2>Preconditions</h2>
|
||||||
|
@ -24,9 +26,6 @@
|
||||||
<li>
|
<li>
|
||||||
The device is plugged in to the charger before this test is run.
|
The device is plugged in to the charger before this test is run.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
The battery must not be full or reach full capacity during the time the test is run.
|
|
||||||
</li>
|
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<div id="note">
|
<div id="note">
|
||||||
|
@ -41,10 +40,21 @@
|
||||||
|
|
||||||
setup({ explicit_timeout: true });
|
setup({ explicit_timeout: true });
|
||||||
|
|
||||||
var onchargingchange_test = async_test('When the device is unplugged in and its charging state is updated, must set the charging attribute\'s value to false and fire a chargingchange event.');
|
var onchargingchange_test = async_test(
|
||||||
var onchargingtimechange_test = async_test('When the device is unplugged in and its charging time is updated, must set the chargingTime attribute\'s value to Infinity and fire a chargingtimechange event.');
|
'When the device is unplugged in and its charging state is updated, ' +
|
||||||
var ondischargingtimechange_test = async_test('When the device is unplugged in and its discharging time is updated, must set the dischargingTime attribute\'s value and fire a dischargingtimechange event.');
|
'must set the charging attribute\'s value to false and ' +
|
||||||
var onlevelchange_test = async_test('When the device is plugged in and the battery level is updated, must set the level attribute\'s value and fire a levelchange event.');
|
'fire a chargingchange event.');
|
||||||
|
var onchargingtimechange_test = async_test(
|
||||||
|
'When the device is unplugged in and its charging time is updated, ' +
|
||||||
|
'must set the chargingTime attribute\'s value to Infinity and ' +
|
||||||
|
'fire a chargingtimechange event.');
|
||||||
|
var ondischargingtimechange_test = async_test(
|
||||||
|
'When the device is unplugged in and its discharging time is updated, ' +
|
||||||
|
'must set the dischargingTime attribute\'s value and ' +
|
||||||
|
'fire a dischargingtimechange event.');
|
||||||
|
var onlevelchange_test = async_test(
|
||||||
|
'When the device is unplugged in and the battery level is updated, ' +
|
||||||
|
'must set the level attribute\'s value and fire a levelchange event.');
|
||||||
|
|
||||||
var batterySuccess = function (battery) {
|
var batterySuccess = function (battery) {
|
||||||
battery.onchargingchange = onchargingchange_test.step_func(function () {
|
battery.onchargingchange = onchargingchange_test.step_func(function () {
|
||||||
|
@ -53,12 +63,14 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
battery.onchargingtimechange = onchargingtimechange_test.step_func(function () {
|
battery.onchargingtimechange = onchargingtimechange_test.step_func(function () {
|
||||||
assert_equals(battery.chargingTime, Infinity, 'The value of the chargingTime attribute must be set to Infinity.');
|
assert_equals(battery.chargingTime, Infinity,
|
||||||
|
'The value of the chargingTime attribute must be set to Infinity.');
|
||||||
onchargingtimechange_test.done();
|
onchargingtimechange_test.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
battery.ondischargingtimechange = ondischargingtimechange_test.step_func(function () {
|
battery.ondischargingtimechange = ondischargingtimechange_test.step_func(function () {
|
||||||
assert_less_than(battery.dischargingTime, Infinity, 'The value of the dischargingTime attribute must be set to the remaining discharging time.');
|
assert_less_than(battery.dischargingTime, Infinity,
|
||||||
|
'The value of the dischargingTime attribute must be set to the remaining discharging time.');
|
||||||
ondischargingtimechange_test.done();
|
ondischargingtimechange_test.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -52,4 +52,33 @@ test(function() {
|
||||||
var evt = document.createEvent("U\u0131Event");
|
var evt = document.createEvent("U\u0131Event");
|
||||||
});
|
});
|
||||||
}, "Should throw NOT_SUPPORTED_ERR for unrecognized arguments");
|
}, "Should throw NOT_SUPPORTED_ERR for unrecognized arguments");
|
||||||
|
|
||||||
|
/*
|
||||||
|
The following are event interfaces which do actually exist, but must still
|
||||||
|
throw since they're absent from the table in the spec
|
||||||
|
for document.createEvent().
|
||||||
|
This list is not exhaustive.
|
||||||
|
*/
|
||||||
|
var someNonCreateableEvents = [
|
||||||
|
"AnimationEvent",
|
||||||
|
"DragEvent",
|
||||||
|
"ErrorEvent",
|
||||||
|
"FocusEvent",
|
||||||
|
"PointerEvent",
|
||||||
|
"TransitionEvent",
|
||||||
|
"WheelEvent"
|
||||||
|
];
|
||||||
|
someNonCreateableEvents.forEach(function (eventInterface) {
|
||||||
|
test(function () {
|
||||||
|
assert_throws("NOT_SUPPORTED_ERR", function () {
|
||||||
|
var evt = document.createEvent(eventInterface);
|
||||||
|
});
|
||||||
|
}, 'Should throw NOT_SUPPORTED_ERR for non-legacy event interface "' + eventInterface + '"');
|
||||||
|
|
||||||
|
test(function () {
|
||||||
|
assert_throws("NOT_SUPPORTED_ERR", function () {
|
||||||
|
var evt = document.createEvent(eventInterface + "s");
|
||||||
|
});
|
||||||
|
}, 'Should throw NOT_SUPPORTED_ERR for pluralized non-legacy event interface "' + eventInterface + '"');
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -32,8 +32,9 @@
|
||||||
var headerDict = {"name1": "value1",
|
var headerDict = {"name1": "value1",
|
||||||
"name2": "value2",
|
"name2": "value2",
|
||||||
"name3": "value3",
|
"name3": "value3",
|
||||||
"name5": undefined,
|
|
||||||
"name4": null,
|
"name4": null,
|
||||||
|
"name5": undefined,
|
||||||
|
"name6": 1,
|
||||||
"Content-Type": "value4"
|
"Content-Type": "value4"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,24 +44,28 @@
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
var headers = new Headers(headerSeq);
|
var headers = new Headers(headerSeq);
|
||||||
for (name in headerDict)
|
for (name in headerDict) {
|
||||||
assert_equals(headers.get(name), String(headerDict[name]),
|
assert_equals(headers.get(name), String(headerDict[name]),
|
||||||
"name: " + name + " has value: " + headerDict[name]);
|
"name: " + name + " has value: " + headerDict[name]);
|
||||||
|
}
|
||||||
|
assert_equals(headers.get("length"), null, "init should be treated as a sequence, not as a dictionary");
|
||||||
}, "Create headers with sequence");
|
}, "Create headers with sequence");
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
var headers = new Headers(headerDict);
|
var headers = new Headers(headerDict);
|
||||||
for (name in headerDict)
|
for (name in headerDict) {
|
||||||
assert_equals(headers.get(name), String(headerDict[name]),
|
assert_equals(headers.get(name), String(headerDict[name]),
|
||||||
"name: " + name + " has value: " + headerDict[name]);
|
"name: " + name + " has value: " + headerDict[name]);
|
||||||
|
}
|
||||||
}, "Create headers with OpenEndedDictionary");
|
}, "Create headers with OpenEndedDictionary");
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
var headers = new Headers(headerDict);
|
var headers = new Headers(headerDict);
|
||||||
var headers2 = new Headers(headers);
|
var headers2 = new Headers(headers);
|
||||||
for (name in headerDict)
|
for (name in headerDict) {
|
||||||
assert_equals(headers2.get(name), String(headerDict[name]),
|
assert_equals(headers2.get(name), String(headerDict[name]),
|
||||||
"name: " + name + " has value: " + headerDict[name]);
|
"name: " + name + " has value: " + headerDict[name]);
|
||||||
|
}
|
||||||
}, "Create headers whith existing headers");
|
}, "Create headers whith existing headers");
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
|
@ -102,10 +107,89 @@
|
||||||
var headers = new Headers(headerDict);
|
var headers = new Headers(headerDict);
|
||||||
for (name in headerDict)
|
for (name in headerDict)
|
||||||
assert_equals(headers.get(name), String(headerDict[name]),
|
assert_equals(headers.get(name), String(headerDict[name]),
|
||||||
"name: " + name + "has value: " + headerDict[name]);
|
"name: " + name + " has value: " + headerDict[name]);
|
||||||
|
|
||||||
assert_equals(headers.get("nameNotInHeaders"), null, "header: nameNotInHeaders has no value");
|
assert_equals(headers.get("nameNotInHeaders"), null, "header: nameNotInHeaders has no value");
|
||||||
}, "Check get method");
|
}, "Check get method");
|
||||||
|
|
||||||
|
var headerEntriesDict = {"name1": "value1",
|
||||||
|
"Name2": "value2",
|
||||||
|
"name": "value3",
|
||||||
|
"content-Type": "value4",
|
||||||
|
"Content-Typ": "value5",
|
||||||
|
"Content-Types": "value6"
|
||||||
|
};
|
||||||
|
var sortedHeaderDict = {};
|
||||||
|
var sortedHeaderKeys = Object.keys(headerEntriesDict).map(function(value) {
|
||||||
|
sortedHeaderDict[value.toLowerCase()] = headerEntriesDict[value];
|
||||||
|
return value.toLowerCase();
|
||||||
|
}).sort();
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers(headerEntriesDict);
|
||||||
|
var actual = headers.keys();
|
||||||
|
sortedHeaderKeys.forEach(function(key) {
|
||||||
|
entry = actual.next();
|
||||||
|
assert_false(entry.done);
|
||||||
|
assert_equals(entry.value, key);
|
||||||
|
});
|
||||||
|
assert_true(actual.next().done);
|
||||||
|
assert_true(actual.next().done);
|
||||||
|
}, "Check keys method");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers(headerEntriesDict);
|
||||||
|
var actual = headers.values();
|
||||||
|
|
||||||
|
sortedHeaderKeys.forEach(function(key) {
|
||||||
|
entry = actual.next();
|
||||||
|
assert_false(entry.done);
|
||||||
|
assert_equals(entry.value, sortedHeaderDict[key]);
|
||||||
|
});
|
||||||
|
assert_true(actual.next().done);
|
||||||
|
assert_true(actual.next().done);
|
||||||
|
}, "Check values method");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers(headerEntriesDict);
|
||||||
|
var actual = headers.entries();
|
||||||
|
|
||||||
|
sortedHeaderKeys.forEach(function(key) {
|
||||||
|
entry = actual.next();
|
||||||
|
assert_false(entry.done);
|
||||||
|
assert_equals(entry.value[0], key);
|
||||||
|
assert_equals(entry.value[1], sortedHeaderDict[key]);
|
||||||
|
});
|
||||||
|
assert_true(actual.next().done);
|
||||||
|
assert_true(actual.next().done);
|
||||||
|
}, "Check entries method");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers(headerEntriesDict);
|
||||||
|
var actual = headers[Symbol.iterator]();
|
||||||
|
|
||||||
|
sortedHeaderKeys.forEach(function(key) {
|
||||||
|
entry = actual.next();
|
||||||
|
assert_false(entry.done);
|
||||||
|
assert_equals(entry.value[0], key);
|
||||||
|
assert_equals(entry.value[1], sortedHeaderDict[key]);
|
||||||
|
});
|
||||||
|
assert_true(actual.next().done);
|
||||||
|
assert_true(actual.next().done);
|
||||||
|
}, "Check Symbol.iterator method");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers(headerEntriesDict);
|
||||||
|
var reference = sortedHeaderKeys[Symbol.iterator]();
|
||||||
|
headers.forEach(function(value, key, container) {
|
||||||
|
assert_equals(headers, container);
|
||||||
|
entry = reference.next();
|
||||||
|
assert_false(entry.done);
|
||||||
|
assert_equals(key, entry.value);
|
||||||
|
assert_equals(value, sortedHeaderDict[entry.value]);
|
||||||
|
});
|
||||||
|
assert_true(reference.next().done);
|
||||||
|
}, "Check forEach method");
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -12,55 +12,96 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
assert_throws(new TypeError() , function() { new Headers([["name"]]) });
|
assert_throws(new TypeError() , function() { new Headers([["name"]]); });
|
||||||
}, "Create headers giving an array having one string as init argument");
|
}, "Create headers giving an array having one string as init argument");
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
assert_throws(new TypeError() , function() { new Headers([["invalid", "invalidValue1", "invalidValue2"]]) });
|
assert_throws(new TypeError() , function() { new Headers([["invalid", "invalidValue1", "invalidValue2"]]); });
|
||||||
}, "Create headers giving an array having three strings as init argument");
|
}, "Create headers giving an array having three strings as init argument");
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
assert_throws(new TypeError() , function() { new Headers([["invalidĀ", "Value1"]]) });
|
assert_throws(new TypeError() , function() { new Headers([["invalidĀ", "Value1"]]); });
|
||||||
}, "Create headers giving bad header name as init argument");
|
}, "Create headers giving bad header name as init argument");
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
assert_throws(new TypeError() , function() { new Headers([["name", "invalidValueĀ"]]) });
|
assert_throws(new TypeError() , function() { new Headers([["name", "invalidValueĀ"]]); });
|
||||||
}, "Create headers giving bad header value as init argument");
|
}, "Create headers giving bad header value as init argument");
|
||||||
|
|
||||||
|
var badNames = ["invalidĀ", {}];
|
||||||
|
var badValues = ["invalidĀ"];
|
||||||
|
|
||||||
|
badNames.forEach(function(name) {
|
||||||
test(function() {
|
test(function() {
|
||||||
var headers = new Headers();
|
var headers = new Headers();
|
||||||
assert_throws(new TypeError() , function() { headers.get("invalidĀ") });
|
assert_throws(new TypeError() , function() { headers.get(name); });
|
||||||
}, "Check headers get with an invalid name");
|
}, "Check headers get with an invalid name " + name);
|
||||||
|
});
|
||||||
|
|
||||||
|
badNames.forEach(function(name) {
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers();
|
||||||
|
assert_throws(new TypeError() , function() { headers.delete(name); });
|
||||||
|
}, "Check headers delete with an invalid name " + name);
|
||||||
|
});
|
||||||
|
|
||||||
|
badNames.forEach(function(name) {
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers();
|
||||||
|
assert_throws(new TypeError() , function() { headers.has(name); });
|
||||||
|
}, "Check headers has with an invalid name " + name);
|
||||||
|
});
|
||||||
|
|
||||||
|
badNames.forEach(function(name) {
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers();
|
||||||
|
assert_throws(new TypeError() , function() { headers.set(name, "Value1"); });
|
||||||
|
}, "Check headers set with an invalid name " + name);
|
||||||
|
});
|
||||||
|
|
||||||
|
badValues.forEach(function(value) {
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers();
|
||||||
|
assert_throws(new TypeError() , function() { headers.set("name", value); });
|
||||||
|
}, "Check headers set with an invalid value " + value);
|
||||||
|
});
|
||||||
|
|
||||||
|
badNames.forEach(function(name) {
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers();
|
||||||
|
assert_throws(new TypeError() , function() { headers.append("invalidĀ", "Value1"); });
|
||||||
|
}, "Check headers append with an invalid name " + name);
|
||||||
|
});
|
||||||
|
|
||||||
|
badValues.forEach(function(value) {
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers();
|
||||||
|
assert_throws(new TypeError() , function() { headers.append("name", value); });
|
||||||
|
}, "Check headers append with an invalid value " + value);
|
||||||
|
});
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
var headers = new Headers();
|
var headers = new Headers([["name", "value"]]);
|
||||||
assert_throws(new TypeError() , function() { headers.delete("invalidĀ") });
|
assert_throws(new TypeError() , function() { headers.forEach(); });
|
||||||
}, "Check headers delete with an invalid name");
|
assert_throws(new TypeError() , function() { headers.forEach(undefined); });
|
||||||
|
assert_throws(new TypeError() , function() { headers.forEach(1); });
|
||||||
|
}, "Headers forEach throws if argument is not callable");
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
var headers = new Headers();
|
var headers = new Headers([["name1", "value1"], ["name2", "value2"], ["name3", "value3"]]);
|
||||||
assert_throws(new TypeError() , function() { headers.has("invalidĀ") });
|
var counter = 0;
|
||||||
}, "Check headers has with an invalid name");
|
try {
|
||||||
|
headers.forEach(function(value, name) {
|
||||||
test(function() {
|
counter++;
|
||||||
var headers = new Headers();
|
if (name == "name2")
|
||||||
assert_throws(new TypeError() , function() { headers.set("invalidĀ", "Value1") });
|
throw "error";
|
||||||
}, "Check headers set with an invalid name");
|
});
|
||||||
|
} catch (e) {
|
||||||
test(function() {
|
assert_equals(counter, 2);
|
||||||
var headers = new Headers();
|
assert_equals(e, "error");
|
||||||
assert_throws(new TypeError() , function() { headers.set("name", "invalidValueĀ") });
|
return;
|
||||||
}, "Check headers set with an invalid value");
|
}
|
||||||
|
assert_unreached();
|
||||||
test(function() {
|
}, "Headers forEach loop should stop if callback is throwing exception");
|
||||||
var headers = new Headers();
|
|
||||||
assert_throws(new TypeError() , function() { headers.append("invalidĀ", "Value1") });
|
|
||||||
}, "Check headers append with an invalid name");
|
|
||||||
|
|
||||||
test(function() {
|
|
||||||
var headers = new Headers();
|
|
||||||
assert_throws(new TypeError() , function() { headers.append("name", "invalidValueĀ") });
|
|
||||||
}, "Check headers append with an invalid value");
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -0,0 +1,150 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Request Headers</title>
|
||||||
|
<meta name="help" href="https://fetch.spec.whatwg.org/#request">
|
||||||
|
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
var validRequestHeaders = [
|
||||||
|
["Content-Type", "OK"],
|
||||||
|
["Potato", "OK"],
|
||||||
|
["proxy", "OK"],
|
||||||
|
["proxya", "OK"],
|
||||||
|
["sec", "OK"],
|
||||||
|
["secb", "OK"],
|
||||||
|
];
|
||||||
|
var invalidRequestHeaders = [
|
||||||
|
["Accept-Charset", "KO"],
|
||||||
|
["accept-charset", "KO"],
|
||||||
|
["ACCEPT-ENCODING", "KO"],
|
||||||
|
["Accept-Encoding", "KO"],
|
||||||
|
["Access-Control-Request-Headers", "KO"],
|
||||||
|
["Access-Control-Request-Method", "KO"],
|
||||||
|
["Connection", "KO"],
|
||||||
|
["Content-Length", "KO"],
|
||||||
|
["Cookie", "KO"],
|
||||||
|
["Cookie2", "KO"],
|
||||||
|
["Date", "KO"],
|
||||||
|
["DNT", "KO"],
|
||||||
|
["Expect", "KO"],
|
||||||
|
["Host", "KO"],
|
||||||
|
["Keep-Alive", "KO"],
|
||||||
|
["Origin", "KO"],
|
||||||
|
["Referer", "KO"],
|
||||||
|
["TE", "KO"],
|
||||||
|
["Trailer", "KO"],
|
||||||
|
["Transfer-Encoding", "KO"],
|
||||||
|
["Upgrade", "KO"],
|
||||||
|
["Via", "KO"],
|
||||||
|
["Proxy-", "KO"],
|
||||||
|
["proxy-a", "KO"],
|
||||||
|
["Sec-", "KO"],
|
||||||
|
["sec-b", "KO"],
|
||||||
|
];
|
||||||
|
|
||||||
|
var validRequestNoCorsHeaders = [
|
||||||
|
["Accept", "OK"],
|
||||||
|
["Accept-Language", "OK"],
|
||||||
|
["content-language", "OK"],
|
||||||
|
["content-type", "application/x-www-form-urlencoded"],
|
||||||
|
["content-type", "application/x-www-form-urlencoded;charset=UTF-8"],
|
||||||
|
["content-type", "multipart/form-data"],
|
||||||
|
["content-type", "multipart/form-data;charset=UTF-8"],
|
||||||
|
["content-TYPE", "text/plain"],
|
||||||
|
["CONTENT-type", "text/plain;charset=UTF-8"],
|
||||||
|
];
|
||||||
|
var invalidRequestNoCorsHeaders = [
|
||||||
|
["Content-Type", "KO"],
|
||||||
|
["Potato", "KO"],
|
||||||
|
["proxy", "KO"],
|
||||||
|
["proxya", "KO"],
|
||||||
|
["sec", "KO"],
|
||||||
|
["secb", "KO"],
|
||||||
|
];
|
||||||
|
|
||||||
|
validRequestHeaders.forEach(function(header) {
|
||||||
|
test(function() {
|
||||||
|
var request = new Request("");
|
||||||
|
request.headers.set(header[0], header[1]);
|
||||||
|
assert_equals(request.headers.get(header[0]), header[1]);
|
||||||
|
}, "Adding valid request header \"" + header[0] + ": " + header[1] + "\"");
|
||||||
|
});
|
||||||
|
invalidRequestHeaders.forEach(function(header) {
|
||||||
|
test(function() {
|
||||||
|
var request = new Request("");
|
||||||
|
request.headers.set(header[0], header[1]);
|
||||||
|
assert_equals(request.headers.get(header[0]), null);
|
||||||
|
}, "Adding invalid request header \"" + header[0] + ": " + header[1] + "\"");
|
||||||
|
});
|
||||||
|
|
||||||
|
validRequestNoCorsHeaders.forEach(function(header) {
|
||||||
|
test(function() {
|
||||||
|
var requestNoCors = new Request("", {"mode": "no-cors"});
|
||||||
|
requestNoCors.headers.set(header[0], header[1]);
|
||||||
|
assert_equals(requestNoCors.headers.get(header[0]), header[1]);
|
||||||
|
}, "Adding valid no-cors request header \"" + header[0] + ": " + header[1] + "\"");
|
||||||
|
});
|
||||||
|
invalidRequestNoCorsHeaders.forEach(function(header) {
|
||||||
|
test(function() {
|
||||||
|
var requestNoCors = new Request("", {"mode": "no-cors"});
|
||||||
|
requestNoCors.headers.set(header[0], header[1]);
|
||||||
|
assert_equals(requestNoCors.headers.get(header[0]), null);
|
||||||
|
}, "Adding invalid no-cors request header \"" + header[0] + ": " + header[1] + "\"");
|
||||||
|
});
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers([["Cookie2", "potato"]]);
|
||||||
|
var request = new Request("", {"headers": headers});
|
||||||
|
assert_equals(request.headers.get("Cookie2"), null);
|
||||||
|
}, "Check that request constructor is filtering headers provided as init parameter");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers([["Content-Type", "potato"]]);
|
||||||
|
var request = new Request("", {"headers": headers, "mode": "no-cors"});
|
||||||
|
assert_equals(request.headers.get("Content-Type"), null);
|
||||||
|
}, "Check that no-cors request constructor is filtering headers provided as init parameter");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var headers = new Headers([["Content-Type", "potato"]]);
|
||||||
|
var initialRequest = new Request("", {"headers": headers});
|
||||||
|
var request = new Request(initialRequest, {"mode": "no-cors"});
|
||||||
|
assert_equals(request.headers.get("Content-Type"), null);
|
||||||
|
}, "Check that no-cors request constructor is filtering headers provided as part of request parameter");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var initialHeaders = new Headers([["Content-Type", "potato"]]);
|
||||||
|
var initialRequest = new Request("", {"headers" : initialHeaders});
|
||||||
|
var request = new Request(initialRequest);
|
||||||
|
assert_equals(request.headers.get("Content-Type"), "potato");
|
||||||
|
}, "Request should get its content-type from the init request");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var initialHeaders = new Headers([["Content-Type", "potato"]]);
|
||||||
|
var initialRequest = new Request("", {"headers" : initialHeaders});
|
||||||
|
var headers = new Headers([]);
|
||||||
|
var request = new Request(initialRequest, {"headers" : headers});
|
||||||
|
assert_false(request.headers.has("Content-Type"));
|
||||||
|
}, "Request should not get its content-type from the init request if init headers are provided");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var initialHeaders = new Headers([["Content-Type-Extra", "potato"]]);
|
||||||
|
var initialRequest = new Request("", {"headers" : initialHeaders, "body" : "this is my plate", "method" : "POST"});
|
||||||
|
var request = new Request(initialRequest);
|
||||||
|
assert_equals(request.headers.get("Content-Type"), "text/plain;charset=UTF-8");
|
||||||
|
}, "Request should get its content-type from the body if none is provided");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var initialHeaders = new Headers([["Content-Type", "potato"]]);
|
||||||
|
var initialRequest = new Request("", {"headers" : initialHeaders, "body" : "this is my plate", "method" : "POST"});
|
||||||
|
var request = new Request(initialRequest);
|
||||||
|
assert_equals(request.headers.get("Content-Type"), "potato");
|
||||||
|
}, "Request should get its content-type from init headers if one is provided");
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -15,7 +15,7 @@ function checkRequest(request, ExpectedValuesDict) {
|
||||||
for (var attribute in ExpectedValuesDict) {
|
for (var attribute in ExpectedValuesDict) {
|
||||||
switch(attribute) {
|
switch(attribute) {
|
||||||
case "headers":
|
case "headers":
|
||||||
for (var key of ExpectedValuesDict["headers"].keys()) {
|
for (var key in ExpectedValuesDict["headers"].keys()) {
|
||||||
assert_equals(request["headers"].get(key), ExpectedValuesDict["headers"].get(key),
|
assert_equals(request["headers"].get(key), ExpectedValuesDict["headers"].get(key),
|
||||||
"Check headers attribute has " + key + ":" + ExpectedValuesDict["headers"].get(key));
|
"Check headers attribute has " + key + ":" + ExpectedValuesDict["headers"].get(key));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue