haikuwebkit/LayoutTests/fast/shadow-dom/fullscreen-in-shadow-fullsc...

11 lines
291 B
Plaintext
Raw Permalink Normal View History

document.webkitFullscreenElement leaks elements inside a shadow tree https://bugs.webkit.org/show_bug.cgi?id=158471 Reviewed by Chris Dumez. Source/WebCore: Fixed the bug by calling the newly added ancestorElementInThisScope in webkitCurrentFullScreenElementForBindings and webkitFullscreenElementForBinding. The specification (https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement) uses "the result of retargeting fullscreen element" and returns null if the result is not in the same tree as the context object. This is equivalent to the algorithm implemented by ancestorElementInThisScope. Observe that the retargeting algorithm (https://dom.spec.whatwg.org/#retarget) finds the lowest common tree scope of the retargetee and the context object. There are two cases to consider. 1. The context object's tree scope is the lowest common tree scope: In this case, an ancestor shadow host or the retargetee itself is in this tree scope. It's sufficient traverse every shadow host to find the one that resides in the same tree scope as the context object. This is precisely what ancestorElementInThisScope does. 2. The context object's tree scope is not the lowest common tree scope: In this case, the context object is inside a shadow tree whose ancestor shadow host is in the lowest common tree scope. In this case, retargeting algorithm finds a node which is not in the same tree as the context object. Thus, the result is null. ancestorElementInThisScope traveres ancestor shadow hosts and returns null if no shadow host's tree scope matches that of the context object's tree scope. Thus, it would return null in this case as desired. Also renamed TreeScope::focusedElement to focusedElementInScope for clarity since Document which inherits from TreeScope also has a distinct member function named focusedElement called by TreeScope::focusedElement, and used ancestorElementInThisScope since it uses the same algorithm. Tests: fast/shadow-dom/activeElement-for-focused-element-in-another-shadow.html fast/shadow-dom/blur-on-shadow-host-with-focused-shadow-content.html fast/shadow-dom/fullscreen-in-shadow-fullscreenElement.html fast/shadow-dom/fullscreen-in-shadow-webkitCurrentFullScreenElement.html fast/shadow-dom/fullscreen-in-slot-fullscreenElement.html fast/shadow-dom/fullscreen-in-slot-webkitCurrentFullScreenElement.html * dom/Document.cpp: (WebCore::Document::removeFocusedNodeOfSubtree): (WebCore::Document::activeElement): * dom/Document.h: (WebCore::Document::webkitCurrentFullScreenElementForBindings): Added. (WebCore::Document::webkitFullscreenElementForBindings): Added. * dom/Document.idl: * dom/Element.cpp: (WebCore::Element::blur): * dom/ShadowRoot.h: (WebCore::ShadowRoot::activeElement): * dom/TreeScope.cpp: (WebCore::TreeScope::ancestorNodeInThisScope): Renamed from ancestorInThisScope for clarity. (WebCore::TreeScope::ancestorElementInThisScope): (WebCore::TreeScope::focusedElementInScope): Renamed from focusedElement to disambiguate it from Document's focusedElement. * dom/TreeScope.h: * editing/VisibleSelection.cpp: (WebCore::adjustPositionForEnd): (WebCore::adjustPositionForStart): * editing/htmlediting.cpp: (WebCore::comparePositions): (WebCore::firstEditablePositionAfterPositionInRoot): (WebCore::lastEditablePositionBeforePositionInRoot): * page/DOMSelection.cpp: (WebCore::selectionShadowAncestor): (WebCore::DOMSelection::shadowAdjustedNode): (WebCore::DOMSelection::shadowAdjustedOffset): * rendering/HitTestResult.cpp: (WebCore::HitTestResult::addNodeToRectBasedTestResult): Added a FIXME here since this is clearly wrong for shadow trees created by author scripts. Source/WebKit/mac: Use the API for bindings to avoid exposing nodes inside a shadow tree. * DOM/DOMDocument.mm: (-[DOMDocument webkitCurrentFullScreenElement]): (-[DOMDocument webkitFullscreenElement]): LayoutTests: Added tests for calling webkitFullscreenElement and webkitCurrentFullScreenElement on a fullscreened element to make sure they return the shadow host instead. Also added two unrelated test cases for temporal regressions I introduced while working on this patch. Skip the fullscreen tests on iOS WK2 since eventSender doesn't work there. * fast/shadow-dom/activeElement-for-focused-element-in-another-shadow-expected.txt: Added. * fast/shadow-dom/activeElement-for-focused-element-in-another-shadow.html: Added. * fast/shadow-dom/blur-on-shadow-host-with-focused-shadow-content-expected.txt: Added. * fast/shadow-dom/blur-on-shadow-host-with-focused-shadow-content.html: Added. * fast/shadow-dom/fullscreen-in-shadow-fullscreenElement-expected.txt: Added. * fast/shadow-dom/fullscreen-in-shadow-fullscreenElement.html: Added. * fast/shadow-dom/fullscreen-in-shadow-webkitCurrentFullScreenElement-expected.txt: Added. * fast/shadow-dom/fullscreen-in-shadow-webkitCurrentFullScreenElement.html: Added. * fast/shadow-dom/fullscreen-in-slot-fullscreenElement-expected.txt: Added. * fast/shadow-dom/fullscreen-in-slot-fullscreenElement.html: Added. * fast/shadow-dom/fullscreen-in-slot-webkitCurrentFullScreenElement-expected.txt: Added. * fast/shadow-dom/fullscreen-in-slot-webkitCurrentFullScreenElement.html: Added. * platform/ios-simulator-wk2/TestExpectations: Canonical link: https://commits.webkit.org/183284@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209628 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-09 22:06:29 +00:00
Test that webkitFullscreenElement retargets the fullscreen element inside a shadow tree.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.webkitFullscreenElement is shadowHost
PASS successfullyParsed is true
TEST COMPLETE
Enter fullscreen