Title: [203849] trunk
Revision
203849
Author
[email protected]
Date
2016-07-28 16:29:37 -0700 (Thu, 28 Jul 2016)

Log Message

window.open.length should be 0
https://bugs.webkit.org/show_bug.cgi?id=160323

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline W3C test now that one more check is passing.

* web-platform-tests/html/dom/interfaces-expected.txt:

Source/WebCore:

window.open.length should be 0 as all its parameters are optional:
- https://html.spec.whatwg.org/multipage/browsers.html#the-window-object

It is 2 in WebKit. Firefox and Chrome agree with the specification and return 0.

No new tests, rebaselined existing test.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::open):
Minor code optimization.

* page/DOMWindow.idl:
Update IDL to match the specification and our custom implementation.
This makes us return the right "length" value.

LayoutTests:

Update existing test to reflect behavior change.

* js/dom/function-length-expected.txt:
* js/dom/function-length.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203848 => 203849)


--- trunk/LayoutTests/ChangeLog	2016-07-28 23:15:07 UTC (rev 203848)
+++ trunk/LayoutTests/ChangeLog	2016-07-28 23:29:37 UTC (rev 203849)
@@ -1,5 +1,17 @@
 2016-07-28  Chris Dumez  <[email protected]>
 
+        window.open.length should be 0
+        https://bugs.webkit.org/show_bug.cgi?id=160323
+
+        Reviewed by Darin Adler.
+
+        Update existing test to reflect behavior change.
+
+        * js/dom/function-length-expected.txt:
+        * js/dom/function-length.html:
+
+2016-07-28  Chris Dumez  <[email protected]>
+
         Parameters to Event.initEvent() should be mandatory
         https://bugs.webkit.org/show_bug.cgi?id=160320
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (203848 => 203849)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-28 23:15:07 UTC (rev 203848)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-28 23:29:37 UTC (rev 203849)
@@ -1,5 +1,16 @@
 2016-07-28  Chris Dumez  <[email protected]>
 
+        window.open.length should be 0
+        https://bugs.webkit.org/show_bug.cgi?id=160323
+
+        Reviewed by Darin Adler.
+
+        Rebaseline W3C test now that one more check is passing.
+
+        * web-platform-tests/html/dom/interfaces-expected.txt:
+
+2016-07-28  Chris Dumez  <[email protected]>
+
         Parameters to Event.initEvent() should be mandatory
         https://bugs.webkit.org/show_bug.cgi?id=160320
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt (203848 => 203849)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2016-07-28 23:15:07 UTC (rev 203848)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2016-07-28 23:29:37 UTC (rev 203849)
@@ -5181,7 +5181,7 @@
 PASS Window interface: attribute opener 
 PASS Window interface: attribute parent 
 PASS Window interface: attribute frameElement 
-FAIL Window interface: operation open(DOMString,DOMString,DOMString,boolean) assert_equals: property has wrong .length expected 0 but got 2
+PASS Window interface: operation open(DOMString,DOMString,DOMString,boolean) 
 PASS Window interface: attribute navigator 
 FAIL Window interface: attribute external assert_own_property: The global object must have a property "external" expected property "external" missing
 PASS Window interface: attribute applicationCache 

Modified: trunk/LayoutTests/js/dom/function-length-expected.txt (203848 => 203849)


--- trunk/LayoutTests/js/dom/function-length-expected.txt	2016-07-28 23:15:07 UTC (rev 203848)
+++ trunk/LayoutTests/js/dom/function-length-expected.txt	2016-07-28 23:29:37 UTC (rev 203849)
@@ -4,7 +4,7 @@
 
 
 PASS window.confirm.length is 0
-PASS window.open.length is 2
+PASS window.open.length is 0
 PASS window.showModalDialog.length is 1
 PASS window.setTimeout.length is 1
 PASS window.clearTimeout.length is 0

Modified: trunk/LayoutTests/js/dom/function-length.html (203848 => 203849)


--- trunk/LayoutTests/js/dom/function-length.html	2016-07-28 23:15:07 UTC (rev 203848)
+++ trunk/LayoutTests/js/dom/function-length.html	2016-07-28 23:29:37 UTC (rev 203849)
@@ -8,7 +8,7 @@
 description("This tests the length property of functions.");
 
 shouldBe('window.confirm.length', '0');
-shouldBe('window.open.length', '2');
+shouldBe('window.open.length', '0');
 shouldBe('window.showModalDialog.length', '1');
 shouldBe('window.setTimeout.length', '1');
 shouldBe('window.clearTimeout.length', '0');

Modified: trunk/Source/WebCore/ChangeLog (203848 => 203849)


--- trunk/Source/WebCore/ChangeLog	2016-07-28 23:15:07 UTC (rev 203848)
+++ trunk/Source/WebCore/ChangeLog	2016-07-28 23:29:37 UTC (rev 203849)
@@ -1,5 +1,27 @@
 2016-07-28  Chris Dumez  <[email protected]>
 
+        window.open.length should be 0
+        https://bugs.webkit.org/show_bug.cgi?id=160323
+
+        Reviewed by Darin Adler.
+
+        window.open.length should be 0 as all its parameters are optional:
+        - https://html.spec.whatwg.org/multipage/browsers.html#the-window-object
+
+        It is 2 in WebKit. Firefox and Chrome agree with the specification and return 0.
+
+        No new tests, rebaselined existing test.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::open):
+        Minor code optimization.
+
+        * page/DOMWindow.idl:
+        Update IDL to match the specification and our custom implementation.
+        This makes us return the right "length" value.
+
+2016-07-28  Chris Dumez  <[email protected]>
+
         Parameters to Event.initEvent() should be mandatory
         https://bugs.webkit.org/show_bug.cgi?id=160320
 

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (203848 => 203849)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2016-07-28 23:15:07 UTC (rev 203848)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2016-07-28 23:29:37 UTC (rev 203849)
@@ -444,7 +444,8 @@
     String urlString = valueToStringWithUndefinedOrNullCheck(&state, state.argument(0));
     if (state.hadException())
         return jsUndefined();
-    AtomicString frameName = state.argument(1).isUndefinedOrNull() ? "_blank" : state.argument(1).toString(&state)->value(&state);
+    JSValue targetValue = state.argument(1);
+    AtomicString target = targetValue.isUndefinedOrNull() ? AtomicString("_blank", AtomicString::ConstructFromLiteral) : targetValue.toString(&state)->toAtomicString(&state);
     if (state.hadException())
         return jsUndefined();
     String windowFeaturesString = valueToStringWithUndefinedOrNullCheck(&state, state.argument(2));
@@ -451,7 +452,7 @@
     if (state.hadException())
         return jsUndefined();
 
-    RefPtr<DOMWindow> openedWindow = wrapped().open(urlString, frameName, windowFeaturesString, activeDOMWindow(&state), firstDOMWindow(&state));
+    RefPtr<DOMWindow> openedWindow = wrapped().open(urlString, target, windowFeaturesString, activeDOMWindow(&state), firstDOMWindow(&state));
     if (!openedWindow)
         return jsUndefined();
     return toJS(&state, openedWindow.get());

Modified: trunk/Source/WebCore/page/DOMWindow.idl (203848 => 203849)


--- trunk/Source/WebCore/page/DOMWindow.idl	2016-07-28 23:15:07 UTC (rev 203848)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2016-07-28 23:29:37 UTC (rev 203849)
@@ -65,9 +65,7 @@
     void print();
     void stop();
 
-    [Custom] DOMWindow open(DOMString url,
-                            DOMString name,
-                            optional DOMString options);
+    [Custom] DOMWindow open(optional DOMString url = "" optional DOMString target = "_blank", [TreatNullAs=EmptyString] optional DOMString features = "");
 
     [Custom] any showModalDialog(DOMString url,
                                        optional any dialogArgs,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to