URLSearchParams iterator snapshots, but it should be live |
||||||||
Issue description
Chrome Version: Version 57.0.2965.0 (Official Build) canary (64-bit)
OS: Windows 10
Test code:
const url = new URL("http://domain.com/?var1=value&var2=");
for (let param of url.searchParams) {
console.log(param[0]);
url.searchParams.delete(param[0]);
}
Should output: var1
In Chrome, outputs: var1, var2
Per spec, https://heycam.github.io/webidl/#dfn-iterator-prototype-object next() method step 7, the list of values to iterate over is re-fetched every time the next() method is called, i.e. is consulted live. However, Chrome's implementation takes a snapshot: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/URLSearchParams.cpp?rcl=0&l=16
I'm not sure if this is a more general problem with our Web IDL iterator implementation, so I'll tag this as a bindings issue in case people want to check the other iterables in our codebase.
Via https://github.com/whatwg/url/issues/188
,
Dec 28 2016
It does look to be bindings releated (or at least, a pattern of subtlety) Buggy: URLSearchParams - copies ( https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/URLSearchParams.cpp?rcl=1482941924&l=16 ) CSS FontFace - copies ( https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/css/FontFaceSet.h?rcl=1482941924&l=123 ) Unclear: RTC Stats - copies ( https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/peerconnection/RTCStatsReport.cpp?rcl=1482941924&l=158 ) (but doesn't expose a mutable interface) Not Buggy: MediaKey Status map - live fetches ( https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/encryptedmedia/MediaKeyStatusMap.cpp?rcl=1482941924&l=70 ) CSS Style Property Map - live fetches ( https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp?rcl=1482941924&l=17 ) Fetch Headers - live fetches ( https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/fetch/Headers.cpp?rcl=1482941924&l=21 ) Form Data - live fetches ( https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/html/FormData.cpp?rcl=1482941924&l=45 )
,
Jan 20 2017
,
Feb 15 2018
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Feb 19 2018
It's still doing it. Is there a wpt test for this behaviour? I think the issue is that the URLSearchParamsIterationSource() constructor copies. It appears it would work okay to pass a pointer instead.
,
Feb 19 2018
As far as I can see, there's url/urlsearchparams-delete.html and url/urlsearchparams-foreach.html, but not something combining both (i.e. deleting inside a loop).
,
Feb 20 2018
,
Mar 30 2018
,
Apr 5 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/1c1627f7a35299d6aa99413a348586508d9a34f3 commit 1c1627f7a35299d6aa99413a348586508d9a34f3 Author: Adam Rice <ricea@chromium.org> Date: Thu Apr 05 07:47:08 2018 Make URLSearchParamsIterationSource not snapshot Previously URLSearchParamsIterationSource iterated over a copy of URLSearchParams, but it is specified in the standard as iterating over the live list. Modify it to reference the original URLSearchParams object instead of making a copy. Also add web-platform tests for delete during foreach, and a chromium- specific test for GC of URLSearchParams during iteration. Remove failing expectations. BUG= 677322 Change-Id: I8c53fd8dd9863fe1146c5b7849d4f08245b37bc1 Reviewed-on: https://chromium-review.googlesource.com/987839 Reviewed-by: Mike West <mkwst@chromium.org> Reviewed-by: Yutaka Hirano <yhirano@chromium.org> Commit-Queue: Adam Rice <ricea@chromium.org> Cr-Commit-Position: refs/heads/master@{#548363} [delete] https://crrev.com/4fc8b7812fee283eed09034ee68dea8cbf39e586/third_party/WebKit/LayoutTests/external/wpt/url/urlsearchparams-foreach-expected.txt [modify] https://crrev.com/1c1627f7a35299d6aa99413a348586508d9a34f3/third_party/WebKit/LayoutTests/external/wpt/url/urlsearchparams-foreach.html [add] https://crrev.com/1c1627f7a35299d6aa99413a348586508d9a34f3/third_party/WebKit/LayoutTests/fast/domurl/chromium/urlsearchparams-iterable-gc.html [modify] https://crrev.com/1c1627f7a35299d6aa99413a348586508d9a34f3/third_party/WebKit/Source/core/url/URLSearchParams.cpp
,
Apr 12 2018
,
Apr 12 2018
|
||||||||
►
Sign in to add a comment |
||||||||
Comment 1 by rsleevi@chromium.org
, Dec 28 2016