See http://jsfiddle.net/tfS83/2/ for demonstration. This is new with iOS 7; tested on 7.0 and 7.0.3. It occurs in Chrome as well as Safari. When using .querySelectorAll on an element, where the selector is an ID selector, the scope of the element is not taken in to account. This is contrary to the behavior of iOS 6 and desktop Safari OSX and Windows, Android, etc.
Created attachment 245850 [details] Patch
The bug was fixed last year: https://bugs.webkit.org/show_bug.cgi?id=119780 The problem was that documents with duplicates ids were not scoping the search correctly. This patch is to add a variant of your tests to improve the test coverage.
Comment on attachment 245850 [details] Patch Attachment 245850 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/7311328 New failing tests: fast/selectors/querySelector-scoped-by-element.html
Created attachment 337943 [details] Archive of layout-test-results from ews101 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-sierra Platform: Mac OS X 10.12.6
Comment on attachment 245850 [details] Patch Attachment 245850 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/7311331 New failing tests: fast/selectors/querySelector-scoped-by-element.html
Created attachment 337944 [details] Archive of layout-test-results from ews105 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews105 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
Comment on attachment 245850 [details] Patch Attachment 245850 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/7311417 New failing tests: fast/selectors/querySelector-scoped-by-element.html
Created attachment 337947 [details] Archive of layout-test-results from ews125 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews125 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.4
Comment on attachment 245850 [details] Patch Attachment 245850 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/7311446 New failing tests: fast/selectors/querySelector-scoped-by-element.html
Created attachment 337950 [details] Archive of layout-test-results from ews114 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews114 Port: mac-sierra Platform: Mac OS X 10.12.6
Comment on attachment 245850 [details] Patch Attachment 245850 [details] did not pass win-ews (win): Output: http://webkit-queues.webkit.org/results/7312201 New failing tests: fast/selectors/querySelector-scoped-by-element.html
Created attachment 337956 [details] Archive of layout-test-results from ews200 for win-future The attached test failures were seen while running run-webkit-tests on the win-ews. Bot: ews200 Port: win-future Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
I can only find these two test cases while searching for "querySelectorAll": https://wpt.fyi/results/dom/nodes?label=master&label=experimental&aligned&view=subtest&q=queryselectorall%20 Do we need to add this test for our coverage or this can be marked as "RESOLVED WONTFIX" at this point since as mentioned in Comment 02 that it was already fixed. Further, I tested this JSBin across all browsers (Chrome Canary 106, Firefox Nightly 105 and Safari 15.6) and they have same output as below: ID Div 1 ID Div 2 1 items. Should always be 1. Class Div 1 Class Div 2 1 items. Should always be 1.
<rdar://problem/98460467>
Pull request: https://github.com/WebKit/WebKit/pull/3197
Committed 253315@main (09386b2b402b): <https://commits.webkit.org/253315@main> Reviewed commits have been landed. Closing PR #3197 and removing active labels.