Add API to access closed shadowRoot in InjectedBundle
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jan 2016 20:29:30 +0000 (20:29 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jan 2016 20:29:30 +0000 (20:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153533

Reviewed by Antti Koivisto.

Source/WebCore:

Always return the shadow root in Element.shadowRootForBindings when the DOM wrapper world has
shadowRootIsAlwaysOpen set to true. Also renamed bindingShadowRoot to shadowRootForBindings
to be consistent.

* bindings/js/DOMWrapperWorld.h:
(WebCore::DOMWrapperWorld::setShadowRootIsAlwaysOpen): Added.
(WebCore::DOMWrapperWorld::shadowRootIsAlwaysOpen): Added.
* dom/Element.cpp:
(WebCore::Element::shadowRootForBindings): Renamed from bindingShadowRoot.
* dom/Element.h:
* dom/Element.idl:

Source/WebKit2:

Added WKBundleScriptWorldMakeAllShadowRootsOpen to make all shadow roots open.
This is needed to keep supporting certain browser-level features such as autofill.

* WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp:
(WKBundleScriptWorldMakeAllShadowRootsOpen): Added.
* WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h:
* WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp:
(WebKit::InjectedBundleScriptWorld::makeAllShadowRootsOpen): Added.
* WebProcess/InjectedBundle/InjectedBundleScriptWorld.h:

Tools:

Added WebKit2 API test for WKBundleScriptWorldMakeAllShadowRootsOpen.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen.cpp: Added.
(TestWebKitAPI::runJavaScriptAlert):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2/InjectedBundleMakrAllShadowRootOpen_Bundle.cpp: Added.
(TestWebKitAPI::InjectedBundleMakrAllShadowRootOpenTest::InjectedBundleMakrAllShadowRootOpenTest):
(TestWebKitAPI::InjectedBundleMakrAllShadowRootOpenTest::initialize):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195686 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/DOMWrapperWorld.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Element.idl
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootOpen_Bundle.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen.cpp [new file with mode: 0644]

index 6abb774..cf5d736 100644 (file)
@@ -1,3 +1,22 @@
+2016-01-27  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Add API to access closed shadowRoot in InjectedBundle
+        https://bugs.webkit.org/show_bug.cgi?id=153533
+
+        Reviewed by Antti Koivisto.
+
+        Always return the shadow root in Element.shadowRootForBindings when the DOM wrapper world has
+        shadowRootIsAlwaysOpen set to true. Also renamed bindingShadowRoot to shadowRootForBindings
+        to be consistent.
+
+        * bindings/js/DOMWrapperWorld.h:
+        (WebCore::DOMWrapperWorld::setShadowRootIsAlwaysOpen): Added.
+        (WebCore::DOMWrapperWorld::shadowRootIsAlwaysOpen): Added.
+        * dom/Element.cpp:
+        (WebCore::Element::shadowRootForBindings): Renamed from bindingShadowRoot.
+        * dom/Element.h:
+        * dom/Element.idl:
+
 2016-01-27  Zhuo Li  <zachli@apple.com>
 
         Need ability to specify alternate image for AutoFill button in input fields.
index e858b55..7294f05 100644 (file)
@@ -46,6 +46,9 @@ public:
     void didCreateWindowShell(ScriptController* scriptController) { m_scriptControllersWithWindowShells.add(scriptController); }
     void didDestroyWindowShell(ScriptController* scriptController) { m_scriptControllersWithWindowShells.remove(scriptController); }
 
+    void setShadowRootIsAlwaysOpen() { m_shadowRootIsAlwaysOpen = true; }
+    bool shadowRootIsAlwaysOpen() const { return m_shadowRootIsAlwaysOpen; }
+
     // FIXME: can we make this private?
     DOMObjectWrapperMap m_wrappers;
     HashMap<CSSValue*, void*> m_cssValueRoots;
@@ -61,6 +64,7 @@ private:
     JSC::VM& m_vm;
     HashSet<ScriptController*> m_scriptControllersWithWindowShells;
     bool m_isNormal;
+    bool m_shadowRootIsAlwaysOpen { false };
 };
 
 DOMWrapperWorld& normalWorld(JSC::VM&);
index 6a540cf..3420176 100644 (file)
@@ -1713,13 +1713,16 @@ RefPtr<ShadowRoot> Element::attachShadow(const Dictionary& dictionary, Exception
     return shadowRoot();
 }
 
-ShadowRoot* Element::bindingShadowRoot() const
+ShadowRoot* Element::shadowRootForBindings(JSC::ExecState& state) const
 {
     ShadowRoot* root = shadowRoot();
     if (!root)
         return nullptr;
-    if (root->type() != ShadowRoot::Type::Open)
-        return nullptr;
+
+    if (root->type() != ShadowRoot::Type::Open) {
+        if (!JSC::jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->world().shadowRootIsAlwaysOpen())
+            return nullptr;
+    }
     return root;
 }
 
index e08401e..c26475c 100644 (file)
@@ -248,7 +248,7 @@ public:
     WEBCORE_EXPORT ShadowRoot* shadowRoot() const;
     WEBCORE_EXPORT RefPtr<ShadowRoot> createShadowRoot(ExceptionCode&);
 
-    ShadowRoot* bindingShadowRoot() const;
+    ShadowRoot* shadowRootForBindings(JSC::ExecState&) const;
     RefPtr<ShadowRoot> attachShadow(const Dictionary&, ExceptionCode&);
 
     ShadowRoot* userAgentShadowRoot() const;
index f08dc04..b987aa0 100644 (file)
     // Shadow DOM API
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
     [Conditional=SHADOW_DOM, RaisesException] ShadowRoot attachShadow(Dictionary options);
-    [Conditional=SHADOW_DOM, ImplementedAs=bindingShadowRoot] readonly attribute ShadowRoot shadowRoot;
+    [Conditional=SHADOW_DOM, ImplementedAs=shadowRootForBindings, CallWith=ScriptState] readonly attribute ShadowRoot shadowRoot;
     [Conditional=SHADOW_DOM, Reflect] attribute DOMString slot;
 #endif
 
index dd689de..f852938 100644 (file)
@@ -1,3 +1,20 @@
+2016-01-27  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Add API to access closed shadowRoot in InjectedBundle
+        https://bugs.webkit.org/show_bug.cgi?id=153533
+
+        Reviewed by Antti Koivisto.
+
+        Added WKBundleScriptWorldMakeAllShadowRootsOpen to make all shadow roots open.
+        This is needed to keep supporting certain browser-level features such as autofill.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp:
+        (WKBundleScriptWorldMakeAllShadowRootsOpen): Added.
+        * WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h:
+        * WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp:
+        (WebKit::InjectedBundleScriptWorld::makeAllShadowRootsOpen): Added.
+        * WebProcess/InjectedBundle/InjectedBundleScriptWorld.h:
+
 2016-01-27  Zhuo Li  <zachli@apple.com>
 
         Need ability to specify alternate image for AutoFill button in input fields.
index 87ccf11..3ae8712 100644 (file)
@@ -52,3 +52,8 @@ void WKBundleScriptWorldClearWrappers(WKBundleScriptWorldRef scriptWorldRef)
 {
     toImpl(scriptWorldRef)->clearWrappers();
 }
+
+void WKBundleScriptWorldMakeAllShadowRootsOpen(WKBundleScriptWorldRef scriptWorldRef)
+{
+    toImpl(scriptWorldRef)->makeAllShadowRootsOpen();
+}
index 9b13fad..f1fb5d3 100644 (file)
@@ -37,6 +37,7 @@ WK_EXPORT WKTypeID WKBundleScriptWorldGetTypeID();
 WK_EXPORT WKBundleScriptWorldRef WKBundleScriptWorldCreateWorld();
 WK_EXPORT WKBundleScriptWorldRef WKBundleScriptWorldNormalWorld();
 WK_EXPORT void WKBundleScriptWorldClearWrappers(WKBundleScriptWorldRef scriptWorld);
+WK_EXPORT void WKBundleScriptWorldMakeAllShadowRootsOpen(WKBundleScriptWorldRef scriptWorld);
 
 #ifdef __cplusplus
 }
index 6cedfde..347ea7b 100644 (file)
@@ -88,4 +88,9 @@ void InjectedBundleScriptWorld::clearWrappers()
     m_world->clearWrappers();
 }
 
+void InjectedBundleScriptWorld::makeAllShadowRootsOpen()
+{
+    m_world->setShadowRootIsAlwaysOpen();
+}
+
 } // namespace WebKit
index 6984415..b3e07f4 100644 (file)
@@ -45,8 +45,9 @@ public:
     virtual ~InjectedBundleScriptWorld();
 
     WebCore::DOMWrapperWorld& coreWorld() const;
-    
+
     void clearWrappers();
+    void makeAllShadowRootsOpen();
 
 private:
     InjectedBundleScriptWorld(PassRefPtr<WebCore::DOMWrapperWorld>);
index 11bf4cd..2f887ce 100644 (file)
@@ -1,3 +1,20 @@
+2016-01-27  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Add API to access closed shadowRoot in InjectedBundle
+        https://bugs.webkit.org/show_bug.cgi?id=153533
+
+        Reviewed by Antti Koivisto.
+
+        Added WebKit2 API test for WKBundleScriptWorldMakeAllShadowRootsOpen.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen.cpp: Added.
+        (TestWebKitAPI::runJavaScriptAlert):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit2/InjectedBundleMakrAllShadowRootOpen_Bundle.cpp: Added.
+        (TestWebKitAPI::InjectedBundleMakrAllShadowRootOpenTest::InjectedBundleMakrAllShadowRootOpenTest):
+        (TestWebKitAPI::InjectedBundleMakrAllShadowRootOpenTest::initialize):
+
 2016-01-27  Jason Marcell  <jmarcell@apple.com>
 
         Refactor logic for parsing Trac revisions into its own function and add logic for parsing git hashes.
index 1233937..a7dc549 100644 (file)
                93F1DB3414DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1DB3314DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp */; };
                93F1DB5714DB1B840024C362 /* NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1DB5614DB1B840024C362 /* NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp */; };
                93F7E86F14DC8E5C00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F7E86E14DC8E5B00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp */; };
+               9B0786A31C58830F00D159E3 /* InjectedBundleMakeAllShadowRootsOpen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B0786A21C58830F00D159E3 /* InjectedBundleMakeAllShadowRootsOpen.cpp */; };
+               9B0786A51C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp */; };
                9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */; };
                9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */; };
                9B7916501BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B79164F1BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm */; };
                93F1DB5614DB1B840024C362 /* NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp; sourceTree = "<group>"; };
                93F7E86B14DC8E4D00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutFrames.cpp; sourceTree = "<group>"; };
                93F7E86E14DC8E5B00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp; sourceTree = "<group>"; };
+               9B0786A21C58830F00D159E3 /* InjectedBundleMakeAllShadowRootsOpen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMakeAllShadowRootsOpen.cpp; sourceTree = "<group>"; };
+               9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMakeAllShadowRootOpen_Bundle.cpp; sourceTree = "<group>"; };
                9B26FC6B159D061000CC3765 /* HTMLFormCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLFormCollectionNamedItem.mm; sourceTree = "<group>"; };
                9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLFormCollectionNamedItem.html; sourceTree = "<group>"; };
                9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLCollectionNamedItem.mm; sourceTree = "<group>"; };
                                9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */,
                                BCB6803F126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp */,
                                BCB68041126FBFF100642A61 /* DocumentStartUserScriptAlertCrash_Bundle.cpp */,
+                               9B0786A21C58830F00D159E3 /* InjectedBundleMakeAllShadowRootsOpen.cpp */,
+                               9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp */,
                                51393E1E1523944A005F39C5 /* DOMWindowExtensionBasic.cpp */,
                                51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */,
                                F6F49C6715545C8D0007F39D /* DOMWindowExtensionNoCache.cpp */,
                                41973B5B1AF2286A006C7B36 /* FileSystem.cpp in Sources */,
                                A1C4FB6E1BACCE50003742D0 /* QuickLook.mm in Sources */,
                                7A5623111AD5AF3E0096B920 /* MenuTypesForMouseEvents.cpp in Sources */,
+                               9B0786A31C58830F00D159E3 /* InjectedBundleMakeAllShadowRootsOpen.cpp in Sources */,
                                1A4F81CC1BDFFD37004E672E /* RemoteObjectRegistry.mm in Sources */,
                                51CB4AD81B3A079C00C1B1C6 /* ModalAlertsSPI.cpp in Sources */,
                                9B7916501BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm in Sources */,
                                C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */,
                                51FCF7A11534B2A000104491 /* ShouldGoToBackForwardListItem_Bundle.cpp in Sources */,
                                7673499D1930C5BB00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp in Sources */,
+                               9B0786A51C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp in Sources */,
                                CE3524F81B1431F60028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp in Sources */,
                                BC22D31914DC68B900FFB1DD /* UserMessage_Bundle.cpp in Sources */,
                                520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootOpen_Bundle.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootOpen_Bundle.cpp
new file mode 100644 (file)
index 0000000..4a923db
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010, 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "InjectedBundleTest.h"
+#include <WebKit/WKBundlePageGroup.h>
+#include <WebKit/WKBundlePrivate.h>
+#include <WebKit/WKBundleScriptWorld.h>
+#include <WebKit/WKRetainPtr.h>
+#include <assert.h>
+
+namespace TestWebKitAPI {
+
+class InjectedBundleMakeAllShadowRootOpenTest : public InjectedBundleTest {
+public:
+    InjectedBundleMakeAllShadowRootOpenTest(const std::string& identifier)
+        : InjectedBundleTest(identifier)
+    { }
+
+    virtual void initialize(WKBundleRef bundle, WKTypeRef userData)
+    {
+        assert(WKGetTypeID(userData) == WKBundlePageGroupGetTypeID());
+        WKBundlePageGroupRef pageGroup = static_cast<WKBundlePageGroupRef>(userData);
+
+        auto world = WKBundleScriptWorldCreateWorld();
+        WKBundleScriptWorldMakeAllShadowRootsOpen(world);
+
+        WKRetainPtr<WKStringRef> source(AdoptWK, WKStringCreateWithUTF8CString(
+            "var element = document.createElement('div');"
+            "element.attachShadow({mode: 'closed'});"
+            "alert(element.shadowRoot ? 'PASS' : 'FAIL');"));
+        WKBundleAddUserScript(bundle, pageGroup, world, source.get(), 0, 0, 0, kWKInjectAtDocumentStart, kWKInjectInAllFrames);
+    }
+};
+
+static InjectedBundleTest::Register<InjectedBundleMakeAllShadowRootOpenTest> registrar("InjectedBundleMakeAllShadowRootOpenTest");
+
+} // namespace TestWebKitAPI
+
+#endif
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen.cpp
new file mode 100644 (file)
index 0000000..982e696
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010, 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+#include <WebKit/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+static bool done;
+
+static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
+{
+    ASSERT_NOT_NULL(frame);
+
+    EXPECT_EQ(page, WKFrameGetPage(frame));
+    EXPECT_WK_STREQ("PASS", alertText);
+
+    done = true;
+}
+
+TEST(WebKit2, InjectedBundleMakeAllShadowRootOpenTest)
+{
+    WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifier(WKStringCreateWithUTF8CString("InjectedBundleMakeAllShadowRootOpenTestPageGroup")));
+
+    WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("InjectedBundleMakeAllShadowRootOpenTest", pageGroup.get()));
+    PlatformWebView webView(context.get(), pageGroup.get());
+
+    WKPageUIClientV0 uiClient;
+    memset(&uiClient, 0, sizeof(uiClient));
+
+    uiClient.base.version = 0;
+    uiClient.runJavaScriptAlert = runJavaScriptAlert;
+
+    WKPageSetPageUIClient(webView.page(), &uiClient.base);
+
+    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+
+    Util::run(&done);
+}
+    
+} // namespace TestWebKitAPI
+
+#endif