WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-162620-20160927121641.patch (text/plain), 14.01 KB, created by
Chris Dumez
on 2016-09-27 12:19:39 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2016-09-27 12:19:39 PDT
Size:
14.01 KB
patch
obsolete
>Subversion Revision: 206400 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 4811df7cbf259367d6a299b7e70e524906035e13..537a2ea4e4127cb6ab0025853ec28f6fe25e837f 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,39 @@ >+2016-09-27 Chris Dumez <cdumez@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ 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): >+ > 2016-09-26 Wenson Hsieh <wenson_hsieh@apple.com> > > Seeking video doesn't update seek position >diff --git a/Source/WebCore/bindings/js/JSDocumentCustom.cpp b/Source/WebCore/bindings/js/JSDocumentCustom.cpp >index b20b268f62cedf46dd31a6acd3b75b9767ee8d33..022c17cdd135c1407aca5f442e1ea48a2ad7a1b1 100644 >--- a/Source/WebCore/bindings/js/JSDocumentCustom.cpp >+++ b/Source/WebCore/bindings/js/JSDocumentCustom.cpp >@@ -175,7 +175,7 @@ JSValue JSDocument::getCSSCanvasContext(JSC::ExecState& state) > > void JSDocument::visitAdditionalChildren(SlotVisitor& visitor) > { >- visitor.addOpaqueRoot(wrapped().scriptExecutionContext()); >+ visitor.addOpaqueRoot(static_cast<ScriptExecutionContext*>(&wrapped())); > } > > } // namespace WebCore >diff --git a/Source/WebCore/dom/DOMImplementation.cpp b/Source/WebCore/dom/DOMImplementation.cpp >index c5a7b942da2eaffb0911ca80bd30d54dbc0f9f08..a85e070e3440902025ea3e925d93796c4c1a0e22 100644 >--- a/Source/WebCore/dom/DOMImplementation.cpp >+++ b/Source/WebCore/dom/DOMImplementation.cpp >@@ -114,7 +114,7 @@ static inline Ref<XMLDocument> createXMLDocument(const String& namespaceURI) > ExceptionOr<Ref<XMLDocument>> DOMImplementation::createDocument(const String& namespaceURI, const String& qualifiedName, DocumentType* documentType) > { > auto document = createXMLDocument(namespaceURI); >- >+ document->setContextDocument(m_document.contextDocument()); > document->setSecurityOriginPolicy(m_document.securityOriginPolicy()); > > RefPtr<Element> documentElement; >@@ -153,6 +153,7 @@ Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title) > ASSERT(document->head()); > document->head()->appendChild(titleElement); > } >+ document->setContextDocument(m_document.contextDocument()); > document->setSecurityOriginPolicy(m_document.securityOriginPolicy()); > return document; > } >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index ec0dc03eaead23a37496d3bc8fa59ef05aebbbfa..f18788e3057f74c4f82c3d3ee0f838fbd1e8cea0 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -576,10 +576,11 @@ static bool isAttributeOnAllOwners(const WebCore::QualifiedName& attribute, cons > } > #endif > >-Ref<Document> Document::create(ScriptExecutionContext& context) >+Ref<Document> Document::create(Document& contextDocument) > { > Ref<Document> document = adoptRef(*new Document(nullptr, URL())); >- document->setSecurityOriginPolicy(context.securityOriginPolicy()); >+ document->setContextDocument(contextDocument); >+ document->setSecurityOriginPolicy(contextDocument.securityOriginPolicy()); > > return document; > } >@@ -3505,6 +3506,7 @@ void Document::cloneDataFromDocument(const Document& other) > m_documentURI = other.documentURI(); > > setCompatibilityMode(other.m_compatibilityMode); >+ setContextDocument(other.contextDocument()); > setSecurityOriginPolicy(other.securityOriginPolicy()); > overrideMIMEType(other.contentType()); > setDecoder(other.decoder()); >@@ -4113,6 +4115,13 @@ void Document::takeDOMWindowFrom(Document* document) > ASSERT(m_domWindow->frame() == m_frame); > } > >+Document& Document::contextDocument() const >+{ >+ if (m_contextDocument) >+ return *m_contextDocument.get(); >+ return const_cast<Document&>(*this); >+} >+ > void Document::setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& attributeValue) > { > setAttributeEventListener(eventType, JSLazyEventListener::create(*this, attributeName, attributeValue)); >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index ccaa9d2c54fa35f29e64280293e2cf653598f832..31ff37283d6f76e48b434f7a8d0e84967cc32a42 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -297,7 +297,7 @@ public: > { > return adoptRef(*new Document(frame, url, DefaultDocumentClass, NonRenderedPlaceholder)); > } >- static Ref<Document> create(ScriptExecutionContext&); >+ static Ref<Document> create(Document&); > > virtual ~Document(); > >@@ -771,6 +771,9 @@ public: > // In DOM Level 2, the Document's DOMWindow is called the defaultView. > DOMWindow* defaultView() const { return domWindow(); } > >+ Document& contextDocument() const; >+ void setContextDocument(Document& document) { m_contextDocument = document.createWeakPtr(); } >+ > // Helper functions for forwarding DOMWindow event related tasks to the DOMWindow if it exists. > void setWindowAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value); > void setWindowAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>); >@@ -1411,6 +1414,7 @@ private: > > Frame* m_frame; > RefPtr<DOMWindow> m_domWindow; >+ WeakPtr<Document> m_contextDocument; > > Ref<CachedResourceLoader> m_cachedResourceLoader; > RefPtr<DocumentParser> m_parser; >@@ -1791,7 +1795,7 @@ inline bool Node::isDocumentNode() const > > inline ScriptExecutionContext* Node::scriptExecutionContext() const > { >- return &document(); >+ return &document().contextDocument(); > } > > Element* eventTargetElementForDocument(Document*); >diff --git a/Source/WebCore/dom/Document.idl b/Source/WebCore/dom/Document.idl >index e9ff8b191f8e5193d1bffdfdae42c684f4106e5e..83ae0da21fd552c8fb6511ac6530175c4bb46527 100644 >--- a/Source/WebCore/dom/Document.idl >+++ b/Source/WebCore/dom/Document.idl >@@ -20,7 +20,7 @@ > > [ > Constructor, >- ConstructorCallWith=ScriptExecutionContext, >+ ConstructorCallWith=Document, > CustomToJSObject, > ExportMacro=WEBCORE_EXPORT, > JSCustomHeader, >diff --git a/Source/WebCore/xml/XMLHttpRequest.cpp b/Source/WebCore/xml/XMLHttpRequest.cpp >index 77266a148f3c295babcfca3191631e3fe3dba9f8..217b8b709e88f281373b82e91b2be573dc1c39ed 100644 >--- a/Source/WebCore/xml/XMLHttpRequest.cpp >+++ b/Source/WebCore/xml/XMLHttpRequest.cpp >@@ -199,6 +199,7 @@ Document* XMLHttpRequest::responseXML(ExceptionCode& ec) > m_responseDocument = XMLDocument::create(0, m_url); > // FIXME: Set Last-Modified. > m_responseDocument->setContent(m_responseBuilder.toStringPreserveCapacity()); >+ m_responseDocument->setContextDocument(downcast<Document>(*scriptExecutionContext())); > m_responseDocument->setSecurityOriginPolicy(scriptExecutionContext()->securityOriginPolicy()); > m_responseDocument->overrideMIMEType(mimeType); > >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index 7faca958d4c7b1eb1a521bb10640431e4865c94d..a2317ecfe61086f87bc87fc0d27662b6977e7931 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1 +1,17 @@ >+2016-09-27 Chris Dumez <cdumez@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ * 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. >+ > == Rolled over to ChangeLog-2016-09-26 == >diff --git a/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-false-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-false-expected.txt >index a602e21e440a5b6e1bad6c05fcaa3f95b991ac47..d352ec844fc60b192d234f2473a0be56c8862bb2 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-false-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-false-expected.txt >@@ -1,7 +1,7 @@ > > PASS In window.document with click event > PASS In window.document with load event >-FAIL In window.document.cloneNode(true) assert_array_equals: targets lengths differ, expected 8 got 0 >-FAIL In new Document() assert_array_equals: targets lengths differ, expected 8 got 0 >-FAIL In DOMImplementation.createHTMLDocument() assert_array_equals: targets lengths differ, expected 8 got 0 >+PASS In window.document.cloneNode(true) >+PASS In new Document() >+PASS In DOMImplementation.createHTMLDocument() > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-true-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-true-expected.txt >index 04eb8bfdb7b41d2325c1ff6ee2de5624a440bd93..d352ec844fc60b192d234f2473a0be56c8862bb2 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-true-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-true-expected.txt >@@ -1,7 +1,7 @@ > > PASS In window.document with click event > PASS In window.document with load event >-FAIL In window.document.cloneNode(true) assert_array_equals: targets lengths differ, expected 14 got 0 >-FAIL In new Document() assert_array_equals: targets lengths differ, expected 14 got 0 >-FAIL In DOMImplementation.createHTMLDocument() assert_array_equals: targets lengths differ, expected 14 got 0 >+PASS In window.document.cloneNode(true) >+PASS In new Document() >+PASS In DOMImplementation.createHTMLDocument() > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..a3a8cd27d8b4bc4cb329ec1bca0593e64f587e9a >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document-expected.txt >@@ -0,0 +1,3 @@ >+ >+PASS Custom event on an element in another document >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document.html b/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document.html >new file mode 100644 >index 0000000000000000000000000000000000000000..0252a4f7b61e28f80c64a208224446f3a6297152 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document.html >@@ -0,0 +1,22 @@ >+<!doctype html> >+<title>Custom event on an element in another document</title> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<div id=log></div> >+<script> >+test(function() { >+ var doc = document.implementation.createHTMLDocument("Demo"); >+ var element = doc.createElement("div"); >+ var called = false; >+ element.addEventListener("foo", this.step_func(function(ev) { >+ assert_false(called); >+ called = true; >+ assert_equals(ev.target, element); >+ })); >+ doc.body.appendChild(element); >+ >+ var event = new Event("foo"); >+ element.dispatchEvent(event); >+ assert_true(called); >+}); >+</script> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/dom/events/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/dom/events/w3c-import.log >index 0da5a24c00440a8f5417916db2b4809875c21e6c..c918c2ab8bd78c0a651ceaf2ea58518008f85758 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/dom/events/w3c-import.log >+++ b/LayoutTests/imported/w3c/web-platform-tests/dom/events/w3c-import.log >@@ -29,6 +29,7 @@ List of files: > /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-stopPropagation.html > /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-omitted-capture.html > /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-order.html >+/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document.html > /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-propagation-stopped.html > /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-redispatch.html > /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-reenter.html
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 162620
:
289953
|
289959
|
289973
|
289978
|
289982
|
289991
| 289995