Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstate active flag for iterators #359

Merged
merged 1 commit into from
Aug 8, 2017
Merged

Conversation

ayg
Copy link
Contributor

@ayg ayg commented Oct 29, 2016

This reverts ccf51e8, and fixes
https://www.w3.org/Bugs/Public/show_bug.cgi?id=25412. It brings the
spec back in line with Firefox instead of other browsers. Boris argues
convincingly that the behavior without the active flag is much harder to
spec and test properly, and nobody has a use-case for allowing recursion
here, so it's easier all around to converge on Firefox behavior and just
ban recursion. He doesn't want Firefox to allow recursion unless
someone writes good tests for it, which nobody wants to. Other UAs were
asked for comment on the bug and didn't support or oppose.

@bzbarsky @travisleithead @domenic @cdumez


Preview | Diff

@annevk
Copy link
Member

annevk commented Oct 31, 2016

@dominiccooney @foolip what do you think?

dom.bs Outdated
@@ -8785,6 +8785,10 @@ and {{Range/getBoundingClientRect()}} methods are defined in other specification
to filter and traverse <a>node</a>
<a>trees</a>.

Each {{NodeIterator}} and {{TreeWalker}} object has an associated <dfn export
title=concept-traversal-active for=traversal>active flag</dfn> to avoid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/title/id/ to preserve the old value.

@foolip
Copy link
Member

foolip commented Oct 31, 2016

I guess there already exists some tests for this, or how do we know that only Gecko has the flag now?

@foolip
Copy link
Member

foolip commented Oct 31, 2016

Didn't have to look too far, https://www.w3.org/Bugs/Public/show_bug.cgi?id=25412 has a Live DOM case used to determine current behavior.

I don't have much of an opinion on what behavior makes sense. Is there a recursion check for other cases where a script can call into C++ which synchronously invokes a callback? For dispatchEvent it looks like the limit varies quite a bit: https://software.hixie.ch/utilities/js/live-dom-viewer/saved/4628

Looks like an explicit test for the Gecko behavior should be easier than a test for its absence, does a test already exist in the Gecko tree that you could upstream to web-platform-tests?

@bzbarsky
Copy link

Is there a recursion check for other cases where a script can call into C++ which synchronously invokes a callback?

Well, there's the document.write recursion limitation various browsers do, though it allows some number of levels of nesting....

@ayg
Copy link
Contributor Author

ayg commented Oct 31, 2016

I'm sure we had a wpt test at some point, but I don't see it. It would be easy to write a basic one.

@annevk annevk added the needs tests Moving the issue forward requires someone to write tests label Jan 23, 2017
This reverts ccf51e8, and fixes
https://www.w3.org/Bugs/Public/show_bug.cgi?id=25412.  It brings the
spec back in line with Firefox instead of other browsers.  Boris argues
convincingly that the behavior without the active flag is much harder to
spec and test properly, and nobody has a use-case for allowing recursion
here, so it's easier all around to converge on Firefox behavior and just
ban recursion.  He doesn't want Firefox to allow recursion unless
someone writes good tests for it, which nobody wants to.  Other UAs were
asked for comment on the bug and didn't support or oppose.
ayg added a commit to ayg/web-platform-tests that referenced this pull request Apr 23, 2017
ayg added a commit to ayg/web-platform-tests that referenced this pull request Apr 23, 2017
@ayg
Copy link
Contributor Author

ayg commented Apr 23, 2017

web-platform-tests/wpt#5651 tests this, so would anyone like to review? Firefox passes the tests, and all other browsers presumably fail. (I tested in Chrome and WebKit.)

@annevk
Copy link
Member

annevk commented Apr 24, 2017

Tests and this patch LGTM. However, we don't really know what other browsers want to do. @RByers @cdumez @travisleithead?

@ayg another way forward here is to file bugs against the other browsers. That sometimes helps reaching the right people.

@foolip
Copy link
Member

foolip commented Apr 24, 2017

I'll defer to @tkent-google for this, the failing test would likely show up on his radar first.

Edit: Heh, didn't notice I wasn't the one being asked :)

@zcorpan
Copy link
Member

zcorpan commented Apr 24, 2017

document.write limit is whatwg/html#1954

@cdumez
Copy link

cdumez commented Apr 24, 2017

I do not see any strong reason to allow recursion either. I am fine trying to align WebKit here if Blink guys are on board. If this lands, please file a bug against WebKit.

@tkent-google
Copy link
Collaborator

Adding the flag looks reasonable.

@ayg
Copy link
Contributor Author

ayg commented Aug 6, 2017

We have three out of four browsers in agreement here, and have working tests. Only Edge hasn't replied. Can we merge this?

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to hold off a bit due to infrastructure issues with whatwg.org, but you can consider it merged for all intents and purposes. Apologies for the delay.

annevk pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 7, 2017
@annevk
Copy link
Member

annevk commented Aug 7, 2017

I went ahead and merged the tests. Anyone up for filing browser bugs? (Or have they already been filed?)

I can take care of that too I suppose once it's safe to merge things again.

@annevk annevk merged commit 6a796cc into whatwg:master Aug 8, 2017
hubot pushed a commit to WebKit/WebKit-http that referenced this pull request Aug 9, 2017
https://bugs.webkit.org/show_bug.cgi?id=175312

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Resync WPT tests from upstream to gain test coverage.

* web-platform-tests/dom/traversal/NodeIterator-expected.txt:
* web-platform-tests/dom/traversal/NodeIterator.html:
* web-platform-tests/dom/traversal/TreeWalker-expected.txt:
* web-platform-tests/dom/traversal/TreeWalker.html:

Source/WebCore:

NodeIterator / TreeWalker should no longer allow recursive filters
after the following change to the DOM specification:
- whatwg/dom#359

This patch aligns our behavior with the latest specification.

No new tests, updated existing tests.

* dom/NodeIterator.cpp:
(WebCore::NodeIterator::nextNode):
(WebCore::NodeIterator::previousNode):
Note that we now also call m_candidateNode.clear() before returning an
exception. This was a pre-existing bug that we failed to do so in the
exception case but it became more obvious after this change now that
we throw. This was causing traversal/moz-bug559526.html to fail
otherwise (the filter was called one too many times). The test case
is passing in Firefox (The filter is called 4 times and they throw
each time).

* dom/Traversal.cpp:
(WebCore::NodeIteratorBase::NodeIteratorBase):
(WebCore::NodeIteratorBase::acceptNode):
* dom/Traversal.h:
* dom/TreeWalker.cpp:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@220453 268f45cc-cd09-0410-ab3c-d52691b4dbfc
bertogg pushed a commit to Igalia/webkit that referenced this pull request Sep 4, 2017
https://bugs.webkit.org/show_bug.cgi?id=175312

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Resync WPT tests from upstream to gain test coverage.

* web-platform-tests/dom/traversal/NodeIterator-expected.txt:
* web-platform-tests/dom/traversal/NodeIterator.html:
* web-platform-tests/dom/traversal/TreeWalker-expected.txt:
* web-platform-tests/dom/traversal/TreeWalker.html:

Source/WebCore:

NodeIterator / TreeWalker should no longer allow recursive filters
after the following change to the DOM specification:
- whatwg/dom#359

This patch aligns our behavior with the latest specification.

No new tests, updated existing tests.

* dom/NodeIterator.cpp:
(WebCore::NodeIterator::nextNode):
(WebCore::NodeIterator::previousNode):
Note that we now also call m_candidateNode.clear() before returning an
exception. This was a pre-existing bug that we failed to do so in the
exception case but it became more obvious after this change now that
we throw. This was causing traversal/moz-bug559526.html to fail
otherwise (the filter was called one too many times). The test case
is passing in Firefox (The filter is called 4 times and they throw
each time).

* dom/Traversal.cpp:
(WebCore::NodeIteratorBase::NodeIteratorBase):
(WebCore::NodeIteratorBase::acceptNode):
* dom/Traversal.h:
* dom/TreeWalker.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.18@220640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
rachelandrew pushed a commit to rachelandrew/web-platform-tests that referenced this pull request Nov 8, 2017
JonWBedard pushed a commit to WebKit/WebKit that referenced this pull request Dec 1, 2022
https://bugs.webkit.org/show_bug.cgi?id=175312

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Resync WPT tests from upstream to gain test coverage.

* web-platform-tests/dom/traversal/NodeIterator-expected.txt:
* web-platform-tests/dom/traversal/NodeIterator.html:
* web-platform-tests/dom/traversal/TreeWalker-expected.txt:
* web-platform-tests/dom/traversal/TreeWalker.html:

Source/WebCore:

NodeIterator / TreeWalker should no longer allow recursive filters
after the following change to the DOM specification:
- whatwg/dom#359

This patch aligns our behavior with the latest specification.

No new tests, updated existing tests.

* dom/NodeIterator.cpp:
(WebCore::NodeIterator::nextNode):
(WebCore::NodeIterator::previousNode):
Note that we now also call m_candidateNode.clear() before returning an
exception. This was a pre-existing bug that we failed to do so in the
exception case but it became more obvious after this change now that
we throw. This was causing traversal/moz-bug559526.html to fail
otherwise (the filter was called one too many times). The test case
is passing in Firefox (The filter is called 4 times and they throw
each time).

* dom/Traversal.cpp:
(WebCore::NodeIteratorBase::NodeIteratorBase):
(WebCore::NodeIteratorBase::acceptNode):
* dom/Traversal.h:
* dom/TreeWalker.cpp:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs tests Moving the issue forward requires someone to write tests
Development

Successfully merging this pull request may close these issues.

None yet

7 participants