It should be possible to dispatch events on documents that do not have a browsing...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2016 20:55:20 +0000 (20:55 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2016 20:55:20 +0000 (20:55 +0000)
commit75b2d0fcef411b6accf69e4cd1ae18afea047f0e
treeddac9025f2fc81c2524fde096729e86e1d9a263c
parent76149861b4187459a8551324b4813199e48d3b0b
It should be possible to dispatch events on documents that do not have a browsing context
https://bugs.webkit.org/show_bug.cgi?id=162620

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

* web-platform-tests/dom/events/Event-dispatch-bubbles-false-expected.txt:
* web-platform-tests/dom/events/Event-dispatch-bubbles-true-expected.txt:
Rebaseline several W3C tests now that more checks are passing.

* web-platform-tests/dom/events/Event-dispatch-other-document-expected.txt: Added.
* web-platform-tests/dom/events/Event-dispatch-other-document.html: Added.
* web-platform-tests/dom/events/w3c-import.log:
Import more test coverage from W3C.

Source/WebCore:

It should be possible to dispatch events on documents that do not have a browsing
context (e.g. Documents created using DOMImplementation.createHTMLDocument()).
Gecko and Blink both allow this but WebKit did not.

The approach chosen to support this is similar to the one in Blink. When constructing
a new document (e.g. using DOMImplementation.createHTMLDocument()) we now keep track
of the context document. When requesting the scriptExecutionContext(), we now return
the context document if the document has one instead of the document itself.

Test: imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document.html

* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::visitAdditionalChildren):
* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocument):
(WebCore::DOMImplementation::createHTMLDocument):
* dom/Document.cpp:
(WebCore::Document::create):
(WebCore::Document::cloneDataFromDocument):
(WebCore::Document::contextDocument):
(WebCore::Document::takeDOMWindowFrom): Deleted.
* dom/Document.h:
(WebCore::Document::setContextDocument):
(WebCore::Node::scriptExecutionContext):
(WebCore::Node::isDocumentNode): Deleted.
* dom/Document.idl:
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::responseXML):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206462 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-false-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-true-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/dom/events/w3c-import.log
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDocumentCustom.cpp
Source/WebCore/dom/DOMImplementation.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Document.idl
Source/WebCore/xml/XMLHttpRequest.cpp