Diff
Modified: trunk/LayoutTests/ChangeLog (203028 => 203029)
--- trunk/LayoutTests/ChangeLog 2016-07-09 07:33:28 UTC (rev 203028)
+++ trunk/LayoutTests/ChangeLog 2016-07-09 12:57:37 UTC (rev 203029)
@@ -1,3 +1,13 @@
+2016-07-09 Youenn Fablet <[email protected]>
+
+ Make use of PrivateIdentifier to simplify Fetch Headers built-in checks
+ https://bugs.webkit.org/show_bug.cgi?id=159554
+
+ Reviewed by Alex Christensen.
+
+ * fetch/header-constructor-overriden-expected.txt: Added.
+ * fetch/header-constructor-overriden.html: Added.
+
2016-07-08 Chris Dumez <[email protected]>
adoptNode() changes css class to lowercase for document loaded with XHR responseType = "document"
Added: trunk/LayoutTests/fetch/header-constructor-overriden-expected.txt (0 => 203029)
--- trunk/LayoutTests/fetch/header-constructor-overriden-expected.txt (rev 0)
+++ trunk/LayoutTests/fetch/header-constructor-overriden-expected.txt 2016-07-09 12:57:37 UTC (rev 203029)
@@ -0,0 +1,12 @@
+This test should create a Headers, override the Headers property and try creating new Headers from it.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS headers.get('hello') is "world"
+PASS newHeaders.get('hello') is "world"
+PASS response.headers.get('hello') is "world"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fetch/header-constructor-overriden.html (0 => 203029)
--- trunk/LayoutTests/fetch/header-constructor-overriden.html (rev 0)
+++ trunk/LayoutTests/fetch/header-constructor-overriden.html 2016-07-09 12:57:37 UTC (rev 203029)
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<iframe></iframe>
+<script>
+description("This test should create a Headers, override the Headers property and try creating new Headers from it.");
+
+let array = [ [ 'hello', 'world' ] ];
+var headers = new Headers(array);
+shouldBeEqualToString("headers.get('hello')", "world");
+
+var OldHeaders = Headers;
+
+headers.constructor = null;
+Headers = {};
+window.Headers = {};
+
+var newHeaders = new OldHeaders(headers);
+shouldBeEqualToString("newHeaders.get('hello')", "world");
+
+var response = new Response("", {headers: headers});
+shouldBeEqualToString("response.headers.get('hello')", "world");
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (203028 => 203029)
--- trunk/Source/WebCore/ChangeLog 2016-07-09 07:33:28 UTC (rev 203028)
+++ trunk/Source/WebCore/ChangeLog 2016-07-09 12:57:37 UTC (rev 203029)
@@ -1,3 +1,21 @@
+2016-07-09 Youenn Fablet <[email protected]>
+
+ Make use of PrivateIdentifier to simplify Fetch Headers built-in checks
+ https://bugs.webkit.org/show_bug.cgi?id=159554
+
+ Reviewed by Alex Christensen.
+
+ Test: fetch/header-constructor-overriden.html
+ Patch does not change visible behavior.
+
+ * Modules/fetch/FetchHeaders.idl: Adding PrivateIdentifier to the Headers constructor.
+ * Modules/fetch/FetchHeaders.js:
+ (initializeFetchHeaders): Checking directly with @Headers for improved clarity.
+ * Modules/fetch/FetchResponse.js: Using @Headers to check whether creating a Headers object or not before
+ passsing it to C++ FetchResponse initialize method.
+ (initializeFetchResponse):
+ * bindings/js/WebCoreBuiltinNames.h: Adding Headers private name.
+
2016-07-08 Chris Dumez <[email protected]>
adoptNode() changes css class to lowercase for document loaded with XHR responseType = "document"
Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.idl (203028 => 203029)
--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.idl 2016-07-09 07:33:28 UTC (rev 203028)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.idl 2016-07-09 12:57:37 UTC (rev 203029)
@@ -32,8 +32,9 @@
Exposed=(Window,Worker),
ImplementationLacksVTable,
InterfaceName=Headers,
- JSBuiltinConstructor
-]
+ JSBuiltinConstructor,
+ PrivateIdentifier,
+ PublicIdentifier]
interface FetchHeaders {
[RaisesException] void append(DOMString name, DOMString value);
[RaisesException, ImplementedAs=remove] void delete(DOMString name);
Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.js (203028 => 203029)
--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.js 2016-07-09 07:33:28 UTC (rev 203028)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.js 2016-07-09 12:57:37 UTC (rev 203029)
@@ -35,7 +35,7 @@
if (!@isObject(headersInit))
throw new @TypeError("headersInit must be an object");
- if (headersInit instanceof this.constructor) {
+ if (headersInit instanceof @Headers) {
this.@fillFromJS(headersInit);
return this;
}
Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.js (203028 => 203029)
--- trunk/Source/WebCore/Modules/fetch/FetchResponse.js 2016-07-09 07:33:28 UTC (rev 203028)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.js 2016-07-09 12:57:37 UTC (rev 203029)
@@ -35,11 +35,10 @@
throw new @TypeError("Response init must be an object");
parameters.status = init.status;
parameters.statusText = init.statusText;
- // FIXME: Shield this from user scripts.
if (init.headers)
- parameters.headers = (this.headers.constructor === init.headers.constructor) ? init.headers : new this.headers.constructor(init.headers);
+ parameters.headers = (init.headers instanceof @Headers) ? init.headers : new @Headers(init.headers);
}
-
+
if (parameters.status === @undefined)
parameters.status = 200;
if (parameters.statusText === @undefined)
Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (203028 => 203029)
--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2016-07-09 07:33:28 UTC (rev 203028)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2016-07-09 12:57:37 UTC (rev 203029)
@@ -75,6 +75,7 @@
macro(underlyingSink) \
macro(underlyingSource) \
macro(writing) \
+ macro(Headers) \
macro(MediaStream) \
macro(MediaStreamTrack) \
macro(ReadableStream) \