gecko-dev/testing/web-platform/tests/fetch/api/request/request-headers.html
James Graham 62afd489a0 Bug 1410245 - Update web-platform-tests to revision a372dce582c21c911056273eec042fd9073cbd60, a=testonly
MozReview-Commit-ID: CQzdR66hsXZ


--HG--
rename : testing/web-platform/tests/progress-events/interface.html => testing/web-platform/tests/XMLHttpRequest/progressevent-interface.html
rename : testing/web-platform/tests/cssom/MediaList.xhtml => testing/web-platform/tests/cssom/MediaList2.xhtml
rename : testing/web-platform/tests/old-tests/submission/Microsoft/dragdrop/dragdrop_support.js => testing/web-platform/tests/html/editing/dnd/resources/dragdrop_support.js
rename : testing/web-platform/tests/old-tests/submission/Microsoft/structuredclone/echo.js => testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/echo.js
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/sandbox_011.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/sandbox_011.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_002.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_002.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_003.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_003.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_006.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_006.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_007.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_007.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_012.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_012.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_023.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_023.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_024.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_024.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_028.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_028.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_029.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_029.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/sandbox.pdf => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/sandbox.pdf
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/023.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/023.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/050.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/050.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/067.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/067.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/069.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/069.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/075.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/075.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/077.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/077.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/078.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/078.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/079.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/079.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/101.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/101.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/106-import.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/106-import.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/106-noimport.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/106-noimport.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/107-import.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/107-import.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/107-noimport.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/107-noimport.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/111.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/111.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/112.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/112.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/119.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/119.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/css/background.css => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/css/background.css
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/css/import.css => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/css/import.css
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/count-script-tags.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/count-script-tags.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/find-body.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/find-body.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/find-foo.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/find-foo.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-1.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-1.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-10.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-10.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-11.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-11.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-2.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-2.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-3.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-3.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-4.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-4.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-5.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-5.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-6.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-6.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-7.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-7.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-8.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-8.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-9.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-9.js
rename : testing/web-platform/tests/assumptions/OWNERS => testing/web-platform/tests/infrastructure/assumptions/OWNERS
rename : testing/web-platform/tests/assumptions/canvas-background-ref.html => testing/web-platform/tests/infrastructure/assumptions/canvas-background-ref.html
rename : testing/web-platform/tests/assumptions/canvas-background.html => testing/web-platform/tests/infrastructure/assumptions/canvas-background.html
rename : testing/web-platform/tests/assumptions/html-elements.html => testing/web-platform/tests/infrastructure/assumptions/html-elements.html
rename : testing/web-platform/tests/assumptions/initial-color-ref.html => testing/web-platform/tests/infrastructure/assumptions/initial-color-ref.html
rename : testing/web-platform/tests/assumptions/initial-color.html => testing/web-platform/tests/infrastructure/assumptions/initial-color.html
rename : testing/web-platform/tests/assumptions/medium-font-size-ref.html => testing/web-platform/tests/infrastructure/assumptions/medium-font-size-ref.html
rename : testing/web-platform/tests/assumptions/medium-font-size.html => testing/web-platform/tests/infrastructure/assumptions/medium-font-size.html
rename : testing/web-platform/tests/assumptions/min-font-size-ref.html => testing/web-platform/tests/infrastructure/assumptions/min-font-size-ref.html
rename : testing/web-platform/tests/assumptions/min-font-size.html => testing/web-platform/tests/infrastructure/assumptions/min-font-size.html
rename : testing/web-platform/tests/assumptions/tools/build.sh => testing/web-platform/tests/infrastructure/assumptions/tools/build.sh
rename : testing/web-platform/tests/infrastructure/failing-test.html => testing/web-platform/tests/infrastructure/expected-fail/failing-test.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-exception.html => testing/web-platform/tests/requestidlecallback/callback-exception.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-idle-periods.html => testing/web-platform/tests/requestidlecallback/callback-idle-periods.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-iframe.html => testing/web-platform/tests/requestidlecallback/callback-iframe.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-invoked.html => testing/web-platform/tests/requestidlecallback/callback-invoked.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-multiple-calls.html => testing/web-platform/tests/requestidlecallback/callback-multiple-calls.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-removed-frame.html => testing/web-platform/tests/requestidlecallback/callback-removed-frame.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout-with-raf.html => testing/web-platform/tests/requestidlecallback/callback-timeout-with-raf.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout.html => testing/web-platform/tests/requestidlecallback/callback-timeout.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-xhr-sync.html => testing/web-platform/tests/requestidlecallback/callback-xhr-sync.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/cancel-invoked.html => testing/web-platform/tests/requestidlecallback/cancel-invoked.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/idlharness.html => testing/web-platform/tests/requestidlecallback/idlharness.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/resources/post_name_on_load.html => testing/web-platform/tests/requestidlecallback/resources/post_name_on_load.html
rename : testing/web-platform/tests/webrtc/RTCDTMFSender-insertDTMF.html => testing/web-platform/tests/webrtc/RTCDTMFSender-insertDTMF.https.html
rename : testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange-long.html => testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange-long.https.html
rename : testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange.html => testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange.https.html
rename : testing/web-platform/tests/webrtc/RTCPeerConnection-addTrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-addTrack.https.html
rename : testing/web-platform/tests/webrtc/RTCPeerConnection-ontrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-ontrack.https.html
rename : testing/web-platform/tests/webrtc/RTCPeerConnection-removeTrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-removeTrack.https.html
rename : testing/web-platform/tests/webrtc/RTCRtpReceiver-getContributingSources.html => testing/web-platform/tests/webrtc/RTCRtpReceiver-getContributingSources.https.html
rename : testing/web-platform/tests/webrtc/RTCRtpReceiver-getSynchronizationSources.html => testing/web-platform/tests/webrtc/RTCRtpReceiver-getSynchronizationSources.https.html
2017-10-25 10:45:59 +01:00

186 lines
7.7 KiB
HTML

<!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");
test(function() {
var array = [["hello", "worldAHH"]];
var object = {"hello": 'worldOOH'};
var headers = new Headers(array);
assert_equals(headers.get("hello"), "worldAHH");
var request1 = new Request("", {"headers": headers});
var request2 = new Request("", {"headers": array});
var request3 = new Request("", {"headers": object});
assert_equals(request1.headers.get("hello"), "worldAHH");
assert_equals(request2.headers.get("hello"), "worldAHH");
assert_equals(request3.headers.get("hello"), "worldOOH");
}, "Testing request header creations with various objects");
promise_test(function(test) {
var request = new Request("", {"headers" : [["Content-Type", ""]], "body" : "this is my plate", "method" : "POST"});
return request.blob().then(function(blob) {
assert_equals(blob.type, "", "Blob type should be the empty string");
});
}, "Testing empty Request Content-Type header");
test(function() {
const request1 = new Request("");
assert_equals(request1.headers, request1.headers);
const request2 = new Request("", {"headers": {"X-Foo": "bar"}});
assert_equals(request2.headers, request2.headers);
const headers = request2.headers;
request2.headers.set("X-Foo", "quux");
assert_equals(headers, request2.headers);
headers.set("X-Other-Header", "baz");
assert_equals(headers, request2.headers);
}, "Test that Request.headers has the [SameObject] extended attribute");
</script>
</body>
</html>