Skip to content
Permalink
Browse files
[Fetch API] Implement Fetch API Headers
https://bugs.webkit.org/show_bug.cgi?id=152384

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/fetch/api/headers/headers-basic-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-basic.html: Added.
* web-platform-tests/fetch/api/headers/headers-casing-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-casing.html: Added.
* web-platform-tests/fetch/api/headers/headers-errors-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-errors.html: Added.
* web-platform-tests/fetch/api/headers/headers-idl-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-idl.html: Added.
* web-platform-tests/fetch/api/headers/headers-nameshake-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-nameshake.html: Added.
* web-platform-tests/fetch/api/headers/headers-normalize-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-normalize.html: Added.
* web-platform-tests/fetch/api/headers/headers-structure-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-structure.html: Added.

Source/WebCore:

Adding Fetch Headers API as a wapper around HTTPHeaderMap.

Tests: imported/w3c/web-platform-tests/fetch/api/headers/headers-basic.html
       imported/w3c/web-platform-tests/fetch/api/headers/headers-casing.html
       imported/w3c/web-platform-tests/fetch/api/headers/headers-errors.html
       imported/w3c/web-platform-tests/fetch/api/headers/headers-idl.html
       imported/w3c/web-platform-tests/fetch/api/headers/headers-nameshake.html
       imported/w3c/web-platform-tests/fetch/api/headers/headers-normalize.html
       imported/w3c/web-platform-tests/fetch/api/headers/headers-structure.html

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* Modules/fetch/FetchHeaders.cpp: Added.
(WebCore::FetchHeaders::initializeWith):
(WebCore::isForbiddenHeaderName):
(WebCore::isForbiddenResponseHeaderName):
(WebCore::isSimpleHeader):
(WebCore::canWriteHeader):
(WebCore::FetchHeaders::append):
(WebCore::FetchHeaders::remove):
(WebCore::FetchHeaders::get):
(WebCore::FetchHeaders::has):
(WebCore::FetchHeaders::set):
* Modules/fetch/FetchHeaders.h: Added.
(WebCore::FetchHeaders::create):
(WebCore::FetchHeaders::~FetchHeaders):
(WebCore::FetchHeaders::internalHeaders):
(WebCore::FetchHeaders::FetchHeaders):
* Modules/fetch/FetchHeaders.idl: Added.
* Modules/fetch/FetchHeaders.js: Added.
(initializeFetchHeaders):
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/WebCoreBuiltinNames.h:
* bindings/js/WebCoreJSBuiltins.cpp:
* bindings/js/WebCoreJSBuiltins.h:
(WebCore::JSBuiltinFunctions::JSBuiltinFunctions):
(WebCore::JSBuiltinFunctions::fetchHeadersBuiltins):
* platform/network/HTTPHeaderMap.cpp:
(WebCore::HTTPHeaderMap::contains):
(WebCore::HTTPHeaderMap::remove):
* platform/network/HTTPHeaderMap.h:

LayoutTests:

* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/dom/global-constructors-attributes-expected.txt:
* platform/efl/js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* platform/efl/js/dom/global-constructors-attributes-expected.txt:
* platform/gtk/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt:
* platform/mac/js/dom/global-constructors-attributes-expected.txt:
* platform/win/js/dom/global-constructors-attributes-expected.txt:


Canonical link: https://commits.webkit.org/171489@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
youennf committed Jan 25, 2016
1 parent d0e15bc commit 94ee38941b08ba61b70920bbdd18567df5fda2da
Showing with 1,082 additions and 1 deletion.
  1. +17 −0 LayoutTests/ChangeLog
  2. +22 −0 LayoutTests/imported/w3c/ChangeLog
  3. +15 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-basic-expected.txt
  4. +115 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-basic.html
  5. +6 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-casing-expected.txt
  6. +64 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-casing.html
  7. +18 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-errors-expected.txt
  8. +83 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-errors.html
  9. +24 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-idl-expected.txt
  10. +36 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-idl.html
  11. +6 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-nameshake-expected.txt
  12. +60 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-nameshake.html
  13. +5 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-normalize-expected.txt
  14. +47 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-normalize.html
  15. +10 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-structure-expected.txt
  16. +31 −0 LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-structure.html
  17. +5 −0 LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt
  18. +5 −0 LayoutTests/js/dom/global-constructors-attributes-expected.txt
  19. +5 −0 LayoutTests/platform/efl/js/dom/global-constructors-attributes-dedicated-worker-expected.txt
  20. +5 −0 LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt
  21. +5 −0 LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt
  22. +5 −0 LayoutTests/platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt
  23. +5 −0 LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt
  24. +5 −0 LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt
  25. +5 −0 LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt
  26. +7 −0 Source/WebCore/CMakeLists.txt
  27. +50 −0 Source/WebCore/ChangeLog
  28. +1 −0 Source/WebCore/DerivedSources.cpp
  29. +4 −0 Source/WebCore/DerivedSources.make
  30. +168 −0 Source/WebCore/Modules/fetch/FetchHeaders.cpp
  31. +71 −0 Source/WebCore/Modules/fetch/FetchHeaders.h
  32. +48 −0 Source/WebCore/Modules/fetch/FetchHeaders.idl
  33. +57 −0 Source/WebCore/Modules/fetch/FetchHeaders.js
  34. +34 −0 Source/WebCore/WebCore.xcodeproj/project.pbxproj
  35. +3 −1 Source/WebCore/bindings/js/WebCoreBuiltinNames.h
  36. +4 −0 Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp
  37. +13 −0 Source/WebCore/bindings/js/WebCoreJSBuiltins.h
  38. +16 −0 Source/WebCore/platform/network/HTTPHeaderMap.cpp
  39. +2 −0 Source/WebCore/platform/network/HTTPHeaderMap.h
@@ -1,3 +1,20 @@
2016-01-25 Youenn Fablet <youenn.fablet@crf.canon.fr>

[Fetch API] Implement Fetch API Headers
https://bugs.webkit.org/show_bug.cgi?id=152384

Reviewed by Darin Adler.

* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* js/dom/global-constructors-attributes-expected.txt:
* platform/efl/js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* platform/efl/js/dom/global-constructors-attributes-expected.txt:
* platform/gtk/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt:
* platform/mac/js/dom/global-constructors-attributes-expected.txt:
* platform/win/js/dom/global-constructors-attributes-expected.txt:

2016-01-22 Sergio Villar Senin <svillar@igalia.com>

[css-grid] grid shorthand must reset gap properties to their initial values
@@ -1,3 +1,25 @@
2016-01-25 Youenn Fablet <youenn.fablet@crf.canon.fr>

[Fetch API] Implement Fetch API Headers
https://bugs.webkit.org/show_bug.cgi?id=152384

Reviewed by Darin Adler.

* web-platform-tests/fetch/api/headers/headers-basic-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-basic.html: Added.
* web-platform-tests/fetch/api/headers/headers-casing-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-casing.html: Added.
* web-platform-tests/fetch/api/headers/headers-errors-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-errors.html: Added.
* web-platform-tests/fetch/api/headers/headers-idl-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-idl.html: Added.
* web-platform-tests/fetch/api/headers/headers-nameshake-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-nameshake.html: Added.
* web-platform-tests/fetch/api/headers/headers-normalize-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-normalize.html: Added.
* web-platform-tests/fetch/api/headers/headers-structure-expected.txt: Added.
* web-platform-tests/fetch/api/headers/headers-structure.html: Added.

2016-01-24 Chris Dumez <cdumez@apple.com>

An XMLDocument interface should be exposed on the global Window object
@@ -0,0 +1,15 @@

PASS Create headers from no parameter
PASS Create headers from undefined parameter
PASS Create headers from empty object
PASS Create headers with null should throw
PASS Create headers with 1 should throw
PASS Create headers with sequence
PASS Create headers with OpenEndedDictionary
PASS Create headers whith existing headers
PASS Check append method
PASS Check set method
PASS Check has method
PASS Check delete method
PASS Check get method

@@ -0,0 +1,115 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Headers structure</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#headers">
<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>
test(function() {
new Headers();
}, "Create headers from no parameter");

test(function() {
new Headers(undefined);
}, "Create headers from undefined parameter");

test(function() {
new Headers({});
}, "Create headers from empty object");

var parameters = [null, 1];
parameters.forEach(function(parameter) {
test(function() {
assert_throws(new TypeError(), () => new Headers(parameter));
}, "Create headers with " + parameter + " should throw");
});

var headerDict = {"name1": "value1",
"name2": "value2",
"name3": "value3",
"name4": null,
"name5": undefined,
"name6": 1,
"Content-Type": "value4"
};

var headerSeq = [];
for (var name in headerDict)
headerSeq.push([name, headerDict[name]]);

test(function() {
var headers = new Headers(headerSeq);
for (name in headerDict) {
assert_equals(headers.get(name), String(headerDict[name]),
"name: " + name + " has value: " + headerDict[name]);
}
}, "Create headers with sequence");

test(function() {
var headers = new Headers(headerDict);
for (name in headerDict) {
assert_equals(headers.get(name), String(headerDict[name]),
"name: " + name + " has value: " + headerDict[name]);
}
}, "Create headers with OpenEndedDictionary");

test(function() {
var headers = new Headers(headerDict);
var headers2 = new Headers(headers);
for (name in headerDict) {
assert_equals(headers2.get(name), String(headerDict[name]),
"name: " + name + " has value: " + headerDict[name]);
}
}, "Create headers whith existing headers");

test(function() {
var headers = new Headers();
for (name in headerDict) {
headers.append(name, headerDict[name]);
assert_equals(headers.get(name), String(headerDict[name]),
"name: " + name + " has value: " + headerDict[name]);
}
}, "Check append method");

test(function() {
var headers = new Headers();
for (name in headerDict) {
headers.set(name, headerDict[name]);
assert_equals(headers.get(name), String(headerDict[name]),
"name: " + name + " has value: " + headerDict[name]);
}
}, "Check set method");

test(function() {
var headers = new Headers(headerDict);
for (name in headerDict)
assert_true(headers.has(name),"headers has name " + name);

assert_false(headers.has("nameNotInHeaders"),"headers do not have header: nameNotInHeaders");
}, "Check has method");

test(function() {
var headers = new Headers(headerDict);
for (name in headerDict) {
assert_true(headers.has(name),"headers have a header: " + name);
headers.delete(name)
assert_true(!headers.has(name),"headers do not have anymore a header: " + name);
}
}, "Check delete method");

test(function() {
var headers = new Headers(headerDict);
for (name in headerDict)
assert_equals(headers.get(name), String(headerDict[name]),
"name: " + name + " has value: " + headerDict[name]);

assert_equals(headers.get("nameNotInHeaders"), null, "header: nameNotInHeaders has no value");
}, "Check get method");
</script>
</body>
</html>
@@ -0,0 +1,6 @@

PASS Create headers, names use characters with different case
PASS Check append method, names use characters with different case
PASS Check set method, names use characters with different case
PASS Check delete method, names use characters with different case

@@ -0,0 +1,64 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Headers case management</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-header-list-append">
<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 headerDictCase = {"UPPERCASE": "value1",
"lowercase": "value2",
"mixedCase": "value3",
"Content-TYPE": "value4"
};

function checkHeadersCase(originalName, headersToCheck, expectedDict) {
var lowCaseName = originalName.toLowerCase();
var upCaseName = originalName.toUpperCase();
var expectedValue = expectedDict[originalName];
assert_equals(headersToCheck.get(originalName), expectedValue,
"name: " + originalName + " has value: " + expectedValue);
assert_equals(headersToCheck.get(lowCaseName), expectedValue,
"name: " + lowCaseName + " has value: " + expectedValue);
assert_equals(headersToCheck.get(upCaseName), expectedValue,
"name: " + upCaseName + " has value: " + expectedValue);
}

test(function() {
var headers = new Headers(headerDictCase);
for (name in headerDictCase)
checkHeadersCase(name, headers, headerDictCase)
}, "Create headers, names use characters with different case");

test(function() {
var headers = new Headers();
for (name in headerDictCase) {
headers.append(name, headerDictCase[name]);
checkHeadersCase(name, headers, headerDictCase);
}
}, "Check append method, names use characters with different case");

test(function() {
var headers = new Headers();
for (name in headerDictCase) {
headers.set(name, headerDictCase[name]);
checkHeadersCase(name, headers, headerDictCase);
}
}, "Check set method, names use characters with different case");

test(function() {
var headers = new Headers();
for (name in headerDictCase)
headers.set(name, headerDictCase[name]);
for (name in headerDictCase)
headers.delete(name.toLowerCase());
for (name in headerDictCase)
assert_false(headers.has(name), "header " + name + " should have been deleted");
}, "Check delete method, names use characters with different case");
</script>
</body>
</html>
@@ -0,0 +1,18 @@

PASS Create headers giving an array having one string as init argument
PASS Create headers giving an array having three strings as init argument
PASS Create headers giving bad header name as init argument
PASS Create headers giving bad header value as init argument
PASS Check headers get with an invalid name invalidĀ
PASS Check headers get with an invalid name [object Object]
PASS Check headers delete with an invalid name invalidĀ
PASS Check headers delete with an invalid name [object Object]
PASS Check headers has with an invalid name invalidĀ
PASS Check headers has with an invalid name [object Object]
PASS Check headers set with an invalid name invalidĀ
PASS Check headers set with an invalid name [object Object]
PASS Check headers set with an invalid value invalidĀ
PASS Check headers append with an invalid name invalidĀ
PASS Check headers append with an invalid name [object Object]
PASS Check headers append with an invalid value invalidĀ

@@ -0,0 +1,83 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Headers errors</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#headers">
<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>

test(function() {
assert_throws(new TypeError() , function() { new Headers([["name"]]); });
}, "Create headers giving an array having one string as init argument");

test(function() {
assert_throws(new TypeError() , function() { new Headers([["invalid", "invalidValue1", "invalidValue2"]]); });
}, "Create headers giving an array having three strings as init argument");

test(function() {
assert_throws(new TypeError() , function() { new Headers([["invalidĀ", "Value1"]]); });
}, "Create headers giving bad header name as init argument");

test(function() {
assert_throws(new TypeError() , function() { new Headers([["name", "invalidValueĀ"]]); });
}, "Create headers giving bad header value as init argument");

var badNames = ["invalidĀ", {}];
var badValues = ["invalidĀ"];

badNames.forEach(function(name) {
test(function() {
var headers = new Headers();
assert_throws(new TypeError() , function() { headers.get(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);
});
</script>
</body>
</html>
@@ -0,0 +1,24 @@

FAIL Headers interface: existence and properties of interface object assert_equals: class string of Headers expected "[object Function]" but got "[object HeadersConstructor]"
PASS Headers interface object length
PASS Headers interface object name
PASS Headers interface: existence and properties of interface prototype object
FAIL Headers interface: existence and properties of interface prototype object's "constructor" property assert_true: Headers.prototype.constructor is not writable expected true got false
PASS Headers interface: operation append(ByteString,ByteString)
PASS Headers interface: operation delete(ByteString)
PASS Headers interface: operation get(ByteString)
PASS Headers interface: operation has(ByteString)
PASS Headers interface: operation set(ByteString,ByteString)
PASS Headers must be primary interface of new Headers()
PASS Stringification of new Headers()
PASS Headers interface: new Headers() must inherit property "append" with the proper type (0)
PASS Headers interface: calling append(ByteString,ByteString) on new Headers() with too few arguments must throw TypeError
PASS Headers interface: new Headers() must inherit property "delete" with the proper type (1)
PASS Headers interface: calling delete(ByteString) on new Headers() with too few arguments must throw TypeError
PASS Headers interface: new Headers() must inherit property "get" with the proper type (2)
PASS Headers interface: calling get(ByteString) on new Headers() with too few arguments must throw TypeError
PASS Headers interface: new Headers() must inherit property "has" with the proper type (3)
PASS Headers interface: calling has(ByteString) on new Headers() with too few arguments must throw TypeError
PASS Headers interface: new Headers() must inherit property "set" with the proper type (4)
PASS Headers interface: calling set(ByteString,ByteString) on new Headers() with too few arguments must throw TypeError

0 comments on commit 94ee389

Please sign in to comment.