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

Issue 452093003: Do not fire a DOMSubtreeModified event when Attr.value attribute is set (Closed)

Created:
6 years, 4 months ago by Inactive
Modified:
6 years, 4 months ago
CC:
blink-reviews, blink-reviews-dom_chromium.org, dglazkov+blink, eae+blinkwatch, inferno, rwlbuis, sof
Project:
blink
Visibility:
Public.

Description

Do not fire a DOMSubtreeModified event when Attr.value attribute is set Do not fire a DOMSubtreeModified event when Attr.value attribute is set. This event is deprecated and both Firefox 31 and IE 11 do not fire it in this case. Firing a DOMSubtreeModified event is problematic because it is synchronous and it can lead to calling Attr::setValueInternal() recursively if the JS callback sets Attr.value again. This can lead to serious problems as setValueInternal() calls: 1. Element::willModifyAttribute(oldValue, newValue) 2. Attr::setValue(newValue); 3. Element::didModifyAttribute(newValue) Due to recursivity, we can end up with the following call stack: 1. Element::willModifyAttribute("old-id", "new-id") 2. Attr::setValue("new-id"); 3. Element::willModifyAttribute("new-id", "id-from-callback") 4. Attr::setValue("id-from-callback"); 5. Element::didModifyAttribute("id-from-callback") 6. Element::didModifyAttribute("new-id") After this, the Element's id is "new-id" because the id attribute is updated in Element::didModifyAttribute(). However, the id in the DocumentOrderedMap is "id-from-callback" because the id DocumentOrderedMap is updated in Element::willModifyAttribute(). This mismatch between the DocumentOrderedMap and the actual Element id can cause getElementById() to return incorrect result. Even worse, it can result in a use-after-free (as in Bug 402255) because the DocumentOrderedMap does not hold a reference to the StringImpl used as key, assuming the StringImpl will be kept alive as it is used as 'id' for an Element. BUG=402255 TEST=fast/dom/Attr/set-attr-value-no-DOMSubtreeModified.html Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=180380

Patch Set 1 #

Total comments: 3

Patch Set 2 : Take feedback into consideration #

Patch Set 3 : Fix typo #

Unified diffs Side-by-side diffs Delta from patch set Stats (+32 lines, -14 lines) Patch
A LayoutTests/fast/dom/Attr/set-attr-value-no-DOMSubtreeModified.html View 1 chunk +16 lines, -0 lines 0 comments Download
A LayoutTests/fast/dom/Attr/set-attr-value-no-DOMSubtreeModified-expected.txt View 1 chunk +11 lines, -0 lines 0 comments Download
D LayoutTests/fast/dom/attribute-change-on-mutate.html View 1 chunk +0 lines, -12 lines 0 comments Download
D LayoutTests/fast/dom/attribute-change-on-mutate-expected.txt View 1 chunk +0 lines, -1 line 0 comments Download
M Source/core/dom/ContainerNode.cpp View 1 2 1 chunk +5 lines, -1 line 0 comments Download

Messages

Total messages: 13 (0 generated)
Inactive
6 years, 4 months ago (2014-08-12 21:32:51 UTC) #1
esprehn
https://codereview.chromium.org/452093003/diff/1/Source/core/dom/ContainerNode.cpp File Source/core/dom/ContainerNode.cpp (right): https://codereview.chromium.org/452093003/diff/1/Source/core/dom/ContainerNode.cpp#newcode680 Source/core/dom/ContainerNode.cpp:680: if (shouldDispatchSubtreeModifiedEvent) Can we just do if (!isAttributeNode()) here ...
6 years, 4 months ago (2014-08-12 21:43:02 UTC) #2
Inactive
https://codereview.chromium.org/452093003/diff/1/Source/core/dom/ContainerNode.cpp File Source/core/dom/ContainerNode.cpp (right): https://codereview.chromium.org/452093003/diff/1/Source/core/dom/ContainerNode.cpp#newcode680 Source/core/dom/ContainerNode.cpp:680: if (shouldDispatchSubtreeModifiedEvent) On 2014/08/12 21:43:01, esprehn wrote: > Can ...
6 years, 4 months ago (2014-08-12 21:50:05 UTC) #3
esprehn
On 2014/08/12 at 21:50:05, ch.dumez wrote: > https://codereview.chromium.org/452093003/diff/1/Source/core/dom/ContainerNode.cpp > File Source/core/dom/ContainerNode.cpp (right): > > https://codereview.chromium.org/452093003/diff/1/Source/core/dom/ContainerNode.cpp#newcode680 ...
6 years, 4 months ago (2014-08-12 22:19:06 UTC) #4
Inactive
On 2014/08/12 22:19:06, esprehn wrote: > On 2014/08/12 at 21:50:05, ch.dumez wrote: > > > ...
6 years, 4 months ago (2014-08-12 23:03:30 UTC) #5
esprehn
On 2014/08/12 at 23:03:30, ch.dumez wrote: > ... > > Hmm, if I remember correctly, ...
6 years, 4 months ago (2014-08-12 23:24:33 UTC) #6
Inactive
https://codereview.chromium.org/452093003/diff/1/Source/core/dom/ContainerNode.cpp File Source/core/dom/ContainerNode.cpp (right): https://codereview.chromium.org/452093003/diff/1/Source/core/dom/ContainerNode.cpp#newcode680 Source/core/dom/ContainerNode.cpp:680: if (shouldDispatchSubtreeModifiedEvent) On 2014/08/12 21:43:01, esprehn wrote: > Can ...
6 years, 4 months ago (2014-08-13 00:11:19 UTC) #7
Inactive
ping review.
6 years, 4 months ago (2014-08-15 14:12:08 UTC) #8
esprehn
On 2014/08/15 14:12:08, Chris Dumez wrote: > ping review. Lgtm, typo in the wore "and" ...
6 years, 4 months ago (2014-08-15 14:20:06 UTC) #9
Inactive
The CQ bit was checked by ch.dumez@samsung.com
6 years, 4 months ago (2014-08-15 14:26:04 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/ch.dumez@samsung.com/452093003/40001
6 years, 4 months ago (2014-08-15 14:26:31 UTC) #11
Inactive
On 2014/08/15 14:20:06, esprehn wrote: > On 2014/08/15 14:12:08, Chris Dumez wrote: > > ping ...
6 years, 4 months ago (2014-08-15 14:28:29 UTC) #12
commit-bot: I haz the power
6 years, 4 months ago (2014-08-15 17:50:19 UTC) #13
Message was sent while issue was closed.
Committed patchset #3 (40001) as 180380

Powered by Google App Engine
This is Rietveld 408576698