Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Issue 22929032: Calling window.close() should indicate failure with warning message (Closed)

Created:
7 years, 4 months ago by vivekg_samsung
Modified:
7 years, 1 month ago
CC:
blink-reviews, caseq+blink_chromium.org, loislo+blink_chromium.org, eustas+blink_chromium.org, alph+blink_chromium.org, eae+blinkwatch, yurys+blink_chromium.org, lushnikov+blink_chromium.org, vsevik+blink_chromium.org, pfeldman+blink_chromium.org, dglazkov+blink, paulirish+reviews_chromium.org, apavlov+blink_chromium.org, devtools-reviews_chromium.org, aandrey+blink_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Visibility:
Public.

Description

Calling window.close() should indicate failure with warning message Calling window.close() has no effect on the main page as the calling script has not created the window. In such case, a warning message should be added to the console stating the failure to honor window.close(). Firefox is showing the message "Scripts may not close windows that were not opened by script." The same has been documented here https://developer.mozilla.org/en-US/docs/DOM/window.close Also there is a bug in the DOMWindow::close() which closes the newly opened tab if window.close() is executed from the console of inspector. This is incorrect as the scripts are not allowed to close the window which is not created by it. Also if this is the only tab open, then the browser is also closed. The existing condition checks whether the page is opened by DOM or the page has more than 1 backward/forward history items or the browser doesn't allow the script to close the window. With a new tab opened and the window.close() being called from the inspector console, the second condition i.e. having only 1 item in backward/forward history evaluates to true. Its negated and hence the browser honors the closing of window. Instead, the if condition should first check whether the closing of window is allowed for the given script. Then it should check the rest of the conditions. This way closing of browser/tab is avoided. BUG=170760 R=abarth, pfeldman, yurys Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=160700

Patch Set 1 #

Total comments: 2

Patch Set 2 : #

Patch Set 3 : Patch for landing! #

Unified diffs Side-by-side diffs Delta from patch set Stats (+3 lines, -1 line) Patch
M Source/core/frame/DOMWindow.cpp View 1 2 1 chunk +3 lines, -1 line 0 comments Download

Messages

Total messages: 13 (0 generated)
vivekg__
Please take a look. Thank you!
7 years, 4 months ago (2013-08-22 12:41:26 UTC) #1
vivekg__
Should we notify the user about the failure to honor the window.close() ? https://codereview.chromium.org/22929032/diff/1/Source/core/page/DOMWindow.cpp File ...
7 years, 4 months ago (2013-08-22 14:36:16 UTC) #2
yurys
https://codereview.chromium.org/22929032/diff/1/Source/core/page/DOMWindow.cpp File Source/core/page/DOMWindow.cpp (right): https://codereview.chromium.org/22929032/diff/1/Source/core/page/DOMWindow.cpp#newcode869 Source/core/page/DOMWindow.cpp:869: if (!allowScriptsToCloseWindows || !page->openedByDOM() || page->backForward().count() > 1) { ...
7 years, 4 months ago (2013-08-23 06:12:55 UTC) #3
vivekg__
On 2013/08/23 06:12:55, Yury Semikhatsky wrote: > https://codereview.chromium.org/22929032/diff/1/Source/core/page/DOMWindow.cpp > File Source/core/page/DOMWindow.cpp (right): > > https://codereview.chromium.org/22929032/diff/1/Source/core/page/DOMWindow.cpp#newcode869 ...
7 years, 4 months ago (2013-08-23 08:05:12 UTC) #4
yurys
On 2013/08/23 08:05:12, vivekg_ wrote: > On 2013/08/23 06:12:55, Yury Semikhatsky wrote: > > https://codereview.chromium.org/22929032/diff/1/Source/core/page/DOMWindow.cpp ...
7 years, 4 months ago (2013-08-23 08:19:06 UTC) #5
vivekg__
On 2013/08/23 08:19:06, Yury Semikhatsky wrote: > On 2013/08/23 08:05:12, vivekg_ wrote: > > On ...
7 years, 4 months ago (2013-08-23 08:55:16 UTC) #6
vivekg__
This patch only adds the message. I had to remove the test cases which were ...
7 years, 4 months ago (2013-08-23 12:13:21 UTC) #7
pfeldman
lgtm
7 years, 2 months ago (2013-10-24 13:51:11 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/vivek.vg@samsung.com/22929032/9001
7 years, 2 months ago (2013-10-24 14:31:23 UTC) #9
commit-bot: I haz the power
Failed to apply patch for Source/core/page/DOMWindow.cpp: While running patch -p1 --forward --force --no-backup-if-mismatch; can't find ...
7 years, 2 months ago (2013-10-24 14:31:25 UTC) #10
eseidel
lgtm
7 years, 1 month ago (2013-10-28 06:19:59 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/vivek.vg@samsung.com/22929032/42001
7 years, 1 month ago (2013-10-28 06:20:11 UTC) #12
commit-bot: I haz the power
7 years, 1 month ago (2013-10-28 07:12:41 UTC) #13
Message was sent while issue was closed.
Change committed as 160700

Powered by Google App Engine
This is Rietveld 408576698