- Revision
- 204953
- Author
- [email protected]
- Date
- 2016-08-24 20:06:50 -0700 (Wed, 24 Aug 2016)
Log Message
Location.toString() should be enumerable
https://bugs.webkit.org/show_bug.cgi?id=161179
Reviewed by Geoffrey Garen.
Source/WebCore:
Location.toString() should be enumerable as per:
- https://html.spec.whatwg.org/#location
- http://heycam.github.io/webidl/#es-stringifier
This patch stops hard-coding the toString() operation on the Location
interface and makes the 'href' attribute a stringifier attribute instead,
as per the specification. The generated toString() has the same behavior
as it used to but it is now enumerable, as it should.
No new tests, updated existing test.
* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::toStringFunction): Deleted.
* page/Location.idl:
LayoutTests:
Update existing tests and add layout test coverage.
* fast/dom/Window/window-appendages-cleared-expected.txt:
* fast/dom/toString_attributes-expected.txt:
* fast/dom/toString_attributes.html:
* js/dom/toString-dontEnum-expected.txt:
* js/dom/toString-dontEnum.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (204952 => 204953)
--- trunk/LayoutTests/ChangeLog 2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/ChangeLog 2016-08-25 03:06:50 UTC (rev 204953)
@@ -1,3 +1,18 @@
+2016-08-24 Chris Dumez <[email protected]>
+
+ Location.toString() should be enumerable
+ https://bugs.webkit.org/show_bug.cgi?id=161179
+
+ Reviewed by Geoffrey Garen.
+
+ Update existing tests and add layout test coverage.
+
+ * fast/dom/Window/window-appendages-cleared-expected.txt:
+ * fast/dom/toString_attributes-expected.txt:
+ * fast/dom/toString_attributes.html:
+ * js/dom/toString-dontEnum-expected.txt:
+ * js/dom/toString-dontEnum.html:
+
2016-08-24 Joseph Pecoraro <[email protected]>
Implement `CSS.escape` as per CSSOM
Modified: trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt (204952 => 204953)
--- trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt 2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt 2016-08-25 03:06:50 UTC (rev 204953)
@@ -18,6 +18,7 @@
PASS location.reload == "LEFTOVER" is false
PASS location.replace == "LEFTOVER" is false
PASS location.search == "LEFTOVER" is false
+PASS location.toString == "LEFTOVER" is false
PASS locationbar.visible == "LEFTOVER" is false
PASS menubar.visible == "LEFTOVER" is false
PASS personalbar.visible == "LEFTOVER" is false
Modified: trunk/LayoutTests/fast/dom/toString_attributes-expected.txt (204952 => 204953)
--- trunk/LayoutTests/fast/dom/toString_attributes-expected.txt 2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/fast/dom/toString_attributes-expected.txt 2016-08-25 03:06:50 UTC (rev 204953)
@@ -5,15 +5,21 @@
* HTMLAnchorElement
PASS descriptor.value is an instance of Function
-PASS descriptor.writable is true
+PASS descriptor.writable is !unforgeable
PASS descriptor.enumerable is true
-PASS descriptor.configurable is true
+PASS descriptor.configurable is !unforgeable
* HTMLAreaElement
PASS descriptor.value is an instance of Function
-PASS descriptor.writable is true
+PASS descriptor.writable is !unforgeable
PASS descriptor.enumerable is true
-PASS descriptor.configurable is true
+PASS descriptor.configurable is !unforgeable
+
+* Location
+PASS descriptor.value is an instance of Function
+PASS descriptor.writable is !unforgeable
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is !unforgeable
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/dom/toString_attributes.html (204952 => 204953)
--- trunk/LayoutTests/fast/dom/toString_attributes.html 2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/fast/dom/toString_attributes.html 2016-08-25 03:06:50 UTC (rev 204953)
@@ -5,23 +5,28 @@
<script>
description("Test that the toString() stringifier has the right attributes");
-function testStringifier(object)
+function testStringifier(object, isUnforgeable)
{
- descriptor = Object.getOwnPropertyDescriptor(object.__proto__, "toString");
+ unforgeable = isUnforgeable;
+ descriptor = Object.getOwnPropertyDescriptor(unforgeable ? object : object.__proto__, "toString");
shouldBeType("descriptor.value", "Function");
- shouldBeTrue("descriptor.writable");
+ shouldBe("descriptor.writable", "!unforgeable");
shouldBeTrue("descriptor.enumerable");
- shouldBeTrue("descriptor.configurable");
+ shouldBe("descriptor.configurable", "!unforgeable");
}
debug("* HTMLAnchorElement");
var anchor = document.createElement("a");
-testStringifier(anchor);
+testStringifier(anchor, false);
debug("");
debug("* HTMLAreaElement");
var area = document.createElement("area");
-testStringifier(area);
+testStringifier(area, false);
+
+debug("");
+debug("* Location");
+testStringifier(window.location, true);
</script>
<script src=""
</body>
Modified: trunk/LayoutTests/js/dom/toString-dontEnum-expected.txt (204952 => 204953)
--- trunk/LayoutTests/js/dom/toString-dontEnum-expected.txt 2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/js/dom/toString-dontEnum-expected.txt 2016-08-25 03:06:50 UTC (rev 204953)
@@ -1,6 +1,5 @@
This tests that the toString() function does not enumerate.
-PASS: the toString function is not enumerable for Location.
PASS: the toString function is not enumerable for Selection.
PASS: the toString function is not enumerable for HTMLDivElement.
PASS: the toString function is not enumerable for HTMLDocument.
Modified: trunk/LayoutTests/js/dom/toString-dontEnum.html (204952 => 204953)
--- trunk/LayoutTests/js/dom/toString-dontEnum.html 2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/js/dom/toString-dontEnum.html 2016-08-25 03:06:50 UTC (rev 204953)
@@ -25,7 +25,6 @@
testRunner.dumpAsText();
// DOM objects with custom toString() functions
- test(window.location, "Location");
test(window.getSelection(), "Selection");
// Other DOM objects
Modified: trunk/Source/WebCore/ChangeLog (204952 => 204953)
--- trunk/Source/WebCore/ChangeLog 2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/Source/WebCore/ChangeLog 2016-08-25 03:06:50 UTC (rev 204953)
@@ -1,3 +1,25 @@
+2016-08-24 Chris Dumez <[email protected]>
+
+ Location.toString() should be enumerable
+ https://bugs.webkit.org/show_bug.cgi?id=161179
+
+ Reviewed by Geoffrey Garen.
+
+ Location.toString() should be enumerable as per:
+ - https://html.spec.whatwg.org/#location
+ - http://heycam.github.io/webidl/#es-stringifier
+
+ This patch stops hard-coding the toString() operation on the Location
+ interface and makes the 'href' attribute a stringifier attribute instead,
+ as per the specification. The generated toString() has the same behavior
+ as it used to but it is now enumerable, as it should.
+
+ No new tests, updated existing test.
+
+ * bindings/js/JSLocationCustom.cpp:
+ (WebCore::JSLocation::toStringFunction): Deleted.
+ * page/Location.idl:
+
2016-08-24 Joseph Pecoraro <[email protected]>
Implement `CSS.escape` as per CSSOM
Modified: trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp (204952 => 204953)
--- trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp 2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp 2016-08-25 03:06:50 UTC (rev 204953)
@@ -113,15 +113,6 @@
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
-JSValue JSLocation::toStringFunction(ExecState& state)
-{
- Frame* frame = wrapped().frame();
- if (!frame || !shouldAllowAccessToFrame(&state, frame))
- return jsUndefined();
-
- return jsStringWithCache(&state, wrapped().toString());
-}
-
bool JSLocationPrototype::putDelegate(ExecState* exec, PropertyName propertyName, JSValue, PutPropertySlot&, bool& putResult)
{
putResult = false;
Modified: trunk/Source/WebCore/page/Location.idl (204952 => 204953)
--- trunk/Source/WebCore/page/Location.idl 2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/Source/WebCore/page/Location.idl 2016-08-25 03:06:50 UTC (rev 204953)
@@ -38,7 +38,7 @@
JSCustomNamedGetterOnPrototype,
Unforgeable,
] interface Location {
- [SetterCallWith=ActiveWindow&FirstWindow] attribute USVString href;
+ [SetterCallWith=ActiveWindow&FirstWindow] stringifier attribute USVString href;
[CallWith=ActiveWindow&FirstWindow, ForwardDeclareInHeader] void assign(USVString url);
[DoNotCheckSecurity, CallWith=ActiveWindow&FirstWindow, ForwardDeclareInHeader] void replace(USVString url);
@@ -57,8 +57,4 @@
// FIXME: Add support for SameObject
[Unforgeable, CachedAttribute] readonly attribute FrozenArray<USVString> ancestorOrigins;
-
-#if !(defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT)
- [NotEnumerable, Custom, ImplementedAs=toStringFunction] DOMString toString();
-#endif
};