Return null when window.open() is popup blocked
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2016 19:00:06 +0000 (19:00 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2016 19:00:06 +0000 (19:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162897

Reviewed by Michael Catanzaro.

Source/WebCore:

The return value of window.open() when the popup is blocked should be null:
- https://github.com/whatwg/html/pull/1854
- https://github.com/whatwg/html/issues/1851

Firefox / Edge return null.

No new tests, rebaselined existing tests.

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

LayoutTests:

Rebaseline existing tests to reflect behavior change.

* fast/events/popup-blocked-from-fake-button-click-expected.txt:
* fast/events/popup-blocked-from-fake-button-click.html:
* fast/events/popup-blocked-from-fake-focus-expected.txt:
* fast/events/popup-blocked-from-fake-focus.html:
* fast/events/popup-blocked-from-fake-user-gesture-expected.txt:
* fast/events/popup-blocked-from-fake-user-gesture.html:
* fast/events/popup-blocked-from-untrusted-click-event-on-anchor-expected.txt:
* fast/events/popup-blocked-from-untrusted-click-event-on-anchor.html:
* fast/events/popup-blocking-timers3-expected.txt:
* fast/events/popup-blocking-timers3.html:
* fast/events/popup-blocking-timers4-expected.txt:
* fast/events/popup-blocking-timers4.html:
* fast/events/popup-blocking-timers6-expected.txt:
* fast/events/popup-blocking-timers6.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206777 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/popup-blocked-from-fake-button-click-expected.txt
LayoutTests/fast/events/popup-blocked-from-fake-button-click.html
LayoutTests/fast/events/popup-blocked-from-fake-focus-expected.txt
LayoutTests/fast/events/popup-blocked-from-fake-focus.html
LayoutTests/fast/events/popup-blocked-from-fake-user-gesture-expected.txt
LayoutTests/fast/events/popup-blocked-from-fake-user-gesture.html
LayoutTests/fast/events/popup-blocked-from-untrusted-click-event-on-anchor-expected.txt
LayoutTests/fast/events/popup-blocked-from-untrusted-click-event-on-anchor.html
LayoutTests/fast/events/popup-blocking-timers3-expected.txt
LayoutTests/fast/events/popup-blocking-timers3.html
LayoutTests/fast/events/popup-blocking-timers4-expected.txt
LayoutTests/fast/events/popup-blocking-timers4.html
LayoutTests/fast/events/popup-blocking-timers6-expected.txt
LayoutTests/fast/events/popup-blocking-timers6.html
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

index 6b07e62..96ce74a 100644 (file)
@@ -1,3 +1,27 @@
+2016-10-04  Chris Dumez  <cdumez@apple.com>
+
+        Return null when window.open() is popup blocked
+        https://bugs.webkit.org/show_bug.cgi?id=162897
+
+        Reviewed by Michael Catanzaro.
+
+        Rebaseline existing tests to reflect behavior change.
+
+        * fast/events/popup-blocked-from-fake-button-click-expected.txt:
+        * fast/events/popup-blocked-from-fake-button-click.html:
+        * fast/events/popup-blocked-from-fake-focus-expected.txt:
+        * fast/events/popup-blocked-from-fake-focus.html:
+        * fast/events/popup-blocked-from-fake-user-gesture-expected.txt:
+        * fast/events/popup-blocked-from-fake-user-gesture.html:
+        * fast/events/popup-blocked-from-untrusted-click-event-on-anchor-expected.txt:
+        * fast/events/popup-blocked-from-untrusted-click-event-on-anchor.html:
+        * fast/events/popup-blocking-timers3-expected.txt:
+        * fast/events/popup-blocking-timers3.html:
+        * fast/events/popup-blocking-timers4-expected.txt:
+        * fast/events/popup-blocking-timers4.html:
+        * fast/events/popup-blocking-timers6-expected.txt:
+        * fast/events/popup-blocking-timers6.html:
+
 2016-10-04  Ryan Haddad  <ryanhaddad@apple.com>
 
         Marking http/tests/cache/disk-cache/disk-cache-204-status-code.html as flaky on mac-wk2.
index f6536f5..278cb3d 100644 (file)
@@ -9,7 +9,7 @@
             var win;
             function popup() {
                 win = window.open("about:blank", "blank");
-                shouldBeUndefined("win");
+                shouldBeNull("win");
             }
 
             if (window.testRunner) {
index d52a21b..a95e97a 100644 (file)
@@ -10,7 +10,7 @@
             var win;
             function popup() {
                 win = window.open("about:blank", "blank");
-                shouldBeUndefined("win");
+                shouldBeNull("win");
             }
 
             if (window.testRunner) {
index 0aab909..5bfe483 100644 (file)
@@ -20,7 +20,7 @@
             {
                 window.event = stolenEvent;
                 win = window.open("about:blank", "blank");
-                shouldBeUndefined("win");
+                shouldBeNull("win");
             }
 
             clickHandler = clickHandler1;
index e7e9ebf..16e7fc9 100644 (file)
@@ -9,7 +9,7 @@
             var win;
             function popup() {
                 win = window.open('about:blank','blank','height=200,width=200');
-                shouldBeUndefined("win");
+                shouldBeNull("win");
             }
 
             if (window.testRunner) {
index 6b3b00a..81afb6e 100644 (file)
@@ -2,5 +2,5 @@ Click Here
 Test calling window.open() in a 100 ms interval. A popup should only be allowed on the first execution of the interval.
 PASS newWindow is non-null.
 Test calling window.open() in a 100 ms interval. A popup should only be allowed on the first execution of the interval.
-PASS newWindow is undefined.
+PASS newWindow is null
 
index 5f3f1f1..47778c8 100644 (file)
@@ -22,7 +22,7 @@
                     shouldBeNonNull("newWindow");
                     firstIntervalExecution = false;
                 } else {
-                    shouldBeUndefined("newWindow");
+                    shouldBeNull("newWindow");
                     clearInterval(intervalId);
                     if (window.testRunner)
                         testRunner.notifyDone();
index 18318d3..ba46d83 100644 (file)
@@ -1,4 +1,4 @@
 Click Here
 Test calling window.open() in a nested call to setTimeout(). A popup should not be allowed.
-PASS newWindow is undefined.
+PASS newWindow is null
 
index 9a8a055..f83765e 100644 (file)
@@ -17,7 +17,7 @@
                     newWindow = window.open("about:blank");
                     self.focus();
                     debug("Test calling window.open() in a nested call to setTimeout(). A popup should not be allowed.")
-                    shouldBeUndefined("newWindow");
+                    shouldBeNull("newWindow");
                     if (window.testRunner)
                         testRunner.notifyDone();
                 }, 0);
index eb4dec4..e882387 100644 (file)
@@ -1,4 +1,4 @@
 Click Here
 Test calling window.open() with a 1001 ms delay. A popup should not be allowed.
-PASS newWindow is undefined.
+PASS newWindow is null
 
index 64b0f6f..a19660f 100644 (file)
@@ -16,7 +16,7 @@
                 newWindow = window.open("about:blank");
                 self.focus();
                 debug("Test calling window.open() with a 1001 ms delay. A popup should not be allowed.")
-                shouldBeUndefined("newWindow");
+                shouldBeNull("newWindow");
 
                 if (window.testRunner)
                     testRunner.notifyDone();
index 64e5f87..7ee6802 100644 (file)
@@ -1,5 +1,23 @@
 2016-10-04  Chris Dumez  <cdumez@apple.com>
 
+        Return null when window.open() is popup blocked
+        https://bugs.webkit.org/show_bug.cgi?id=162897
+
+        Reviewed by Michael Catanzaro.
+
+        The return value of window.open() when the popup is blocked should be null:
+        - https://github.com/whatwg/html/pull/1854
+        - https://github.com/whatwg/html/issues/1851
+
+        Firefox / Edge return null.
+
+        No new tests, rebaselined existing tests.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::open):
+
+2016-10-04  Chris Dumez  <cdumez@apple.com>
+
         [Web IDL] Add support for dictionary inheritance
         https://bugs.webkit.org/show_bug.cgi?id=162907
 
index 542c244..62ca9c9 100644 (file)
@@ -433,7 +433,7 @@ JSValue JSDOMWindow::open(ExecState& state)
 
     RefPtr<DOMWindow> openedWindow = wrapped().open(urlString, target, windowFeaturesString, activeDOMWindow(&state), firstDOMWindow(&state));
     if (!openedWindow)
-        return jsUndefined();
+        return jsNull();
     return toJS(&state, openedWindow.get());
 }