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

Issue 1148133005: Window.postMessage() to self can cause document leaks (Closed)

Created:
5 years, 6 months ago by landell
Modified:
5 years, 6 months ago
Reviewers:
haraken, sof, dcheng
CC:
blink-reviews
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

Window.postMessage() to self can cause document leaks When a script does Window.postMessage() a PostMessageTimer object is stored in the LocalDOMWindow until the message has been delivered, or until it is cleared in the destructor of LocalDOMWindow. When a LocalDOMWindow is reset the remaining messages will not be delivered. Any PostMessageTimer objects alive at that point will be kept until the LocalDOMWindow is destroyed. Unfortunately, the PostMessageTimer objects keeps a reference to the source window. If both the source and destination window of the message is the same, the PostMessageTimer can keep that LocalDOMWindow from getting destroyed. Removing the PostMessageTimers when stop() is invoked fixes the problem. BUG= Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=196930

Patch Set 1 #

Patch Set 2 : Remove PostMessageTimers when stopped #

Total comments: 2

Patch Set 3 : Let PostMessageTimer be in charge of its own destruction #

Patch Set 4 : Add layout test #

Total comments: 6

Patch Set 5 : Fix review issues #

Patch Set 6 : Rebase to master #

Unified diffs Side-by-side diffs Delta from patch set Stats (+46 lines, -3 lines) Patch
A LayoutTests/fast/dom/Window/post-message-to-self.html View 1 2 3 4 1 chunk +31 lines, -0 lines 0 comments Download
A + LayoutTests/fast/dom/Window/post-message-to-self-expected.txt View 1 2 3 4 1 chunk +2 lines, -1 line 0 comments Download
M Source/core/frame/LocalDOMWindow.h View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/frame/LocalDOMWindow.cpp View 1 2 3 4 5 4 chunks +12 lines, -2 lines 0 comments Download

Messages

Total messages: 20 (4 generated)
landell
Reviewers: PTAL, thanks
5 years, 6 months ago (2015-06-05 11:53:01 UTC) #2
sof
Won't the one-shot timer still fire & remove itself from that set?
5 years, 6 months ago (2015-06-05 13:01:13 UTC) #4
landell
On 2015/06/05 13:01:13, sof wrote: > Won't the one-shot timer still fire & remove itself ...
5 years, 6 months ago (2015-06-05 13:57:24 UTC) #5
sof
On 2015/06/05 13:57:24, landell wrote: > On 2015/06/05 13:01:13, sof wrote: > > Won't the ...
5 years, 6 months ago (2015-06-05 14:20:25 UTC) #6
landell
On 2015/06/05 14:20:25, sof wrote: > > Overriding stop() is an alternative, along with splitting ...
5 years, 6 months ago (2015-06-08 11:27:08 UTC) #7
sof
Looks good; would it be possible to come up with a test (that the leak ...
5 years, 6 months ago (2015-06-08 11:31:45 UTC) #8
landell
https://codereview.chromium.org/1148133005/diff/20001/Source/core/frame/LocalDOMWindow.cpp File Source/core/frame/LocalDOMWindow.cpp (right): https://codereview.chromium.org/1148133005/diff/20001/Source/core/frame/LocalDOMWindow.cpp#newcode149 Source/core/frame/LocalDOMWindow.cpp:149: // This object is deleted now. On 2015/06/08 11:31:45, ...
5 years, 6 months ago (2015-06-08 11:48:18 UTC) #9
landell
On 2015/06/08 11:31:45, sof wrote: > Looks good; would it be possible to come up ...
5 years, 6 months ago (2015-06-08 11:51:10 UTC) #10
sof
On 2015/06/08 11:51:10, landell wrote: > On 2015/06/08 11:31:45, sof wrote: > > Looks good; ...
5 years, 6 months ago (2015-06-08 13:41:22 UTC) #11
landell
On 2015/06/08 13:41:22, sof wrote: > If you've got some content that's showing up the ...
5 years, 6 months ago (2015-06-10 12:50:39 UTC) #12
sof
Great, thanks - leak steadily reproduces. Could you add the expected output to the CL ...
5 years, 6 months ago (2015-06-10 14:37:25 UTC) #13
landell
https://codereview.chromium.org/1148133005/diff/60001/LayoutTests/fast/dom/Window/post-message-to-self.html File LayoutTests/fast/dom/Window/post-message-to-self.html (right): https://codereview.chromium.org/1148133005/diff/60001/LayoutTests/fast/dom/Window/post-message-to-self.html#newcode8 LayoutTests/fast/dom/Window/post-message-to-self.html:8: On 2015/06/10 14:37:25, sof wrote: > Add > > ...
5 years, 6 months ago (2015-06-11 07:26:05 UTC) #14
sof
lgtm
5 years, 6 months ago (2015-06-11 07:30:35 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1148133005/100001
5 years, 6 months ago (2015-06-11 08:18:27 UTC) #18
haraken
LGTM
5 years, 6 months ago (2015-06-11 08:29:58 UTC) #19
commit-bot: I haz the power
5 years, 6 months ago (2015-06-11 09:16:42 UTC) #20
Message was sent while issue was closed.
Committed patchset #6 (id:100001) as
https://src.chromium.org/viewvc/blink?view=rev&revision=196930

Powered by Google App Engine
This is Rietveld 408576698