WebKit Bugzilla
Attachment 358813 Details for
Bug 193327
: Add WKBundlePage SPI to temporarily force light or dark appearance on a page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193327-20190110115319.patch (text/plain), 18.73 KB, created by
Timothy Hatcher
on 2019-01-10 11:53:20 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Timothy Hatcher
Created:
2019-01-10 11:53:20 PST
Size:
18.73 KB
patch
obsolete
>Subversion Revision: 239836 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 0f00abcd8dc52deb6a7eeb1766e8b016210658e6..4435de62d19478fd76756843d44afc1cee2a9303 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,18 @@ >+2019-01-10 Timothy Hatcher <timothy@apple.com> >+ >+ Add WKBundlePage SPI to temporarily force light or dark appearance on a page. >+ https://bugs.webkit.org/show_bug.cgi?id=193327 >+ rdar://problem/47093222 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests: WebKit.ForceLightAppearanceInBundle API Test >+ >+ * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: >+ (WKBundlePageSetUseDarkAppearance): Added. >+ (WKBundlePageIsUsingDarkAppearance): Added. >+ * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h: >+ > 2019-01-10 Alex Christensen <achristensen@webkit.org> > > REGRESSION(r239815) http/tests/workers/service/serviceworker-private-browsing.https.html test times out >diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp >index d300dc161c6e37b41c7c300046aa3a9971d003cb..400d13954d0df7f0f4170eade6211140876b4d82 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp >@@ -589,6 +589,21 @@ void WKBundlePageConfirmCompositionWithText(WKBundlePageRef pageRef, WKStringRef > WebKit::toImpl(pageRef)->confirmCompositionForTesting(WebKit::toWTFString(text)); > } > >+void WKBundlePageSetUseDarkAppearance(WKBundlePageRef pageRef, bool useDarkAppearance) >+{ >+ WebKit::WebPage* webPage = WebKit::toImpl(pageRef); >+ if (WebCore::Page* page = webPage ? webPage->corePage() : nullptr) >+ page->setUseDarkAppearance(useDarkAppearance); >+} >+ >+bool WKBundlePageIsUsingDarkAppearance(WKBundlePageRef pageRef) >+{ >+ WebKit::WebPage* webPage = WebKit::toImpl(pageRef); >+ if (WebCore::Page* page = webPage ? webPage->corePage() : nullptr) >+ return page->useDarkAppearance(); >+ return false; >+} >+ > bool WKBundlePageCanShowMIMEType(WKBundlePageRef pageRef, WKStringRef mimeTypeRef) > { > return WebKit::toImpl(pageRef)->canShowMIMEType(WebKit::toWTFString(mimeTypeRef)); >diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h >index 8414bcdb03c256ad3774a6d314cdd17e280006ec..d38c4180789b44c8847c9f778f28ef006f1c518a 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h >@@ -77,6 +77,9 @@ WK_EXPORT bool WKBundlePageHasComposition(WKBundlePageRef page); > WK_EXPORT void WKBundlePageConfirmComposition(WKBundlePageRef page); > WK_EXPORT void WKBundlePageConfirmCompositionWithText(WKBundlePageRef page, WKStringRef text); > >+WK_EXPORT void WKBundlePageSetUseDarkAppearance(WKBundlePageRef page, bool useDarkAppearance); >+WK_EXPORT bool WKBundlePageIsUsingDarkAppearance(WKBundlePageRef page); >+ > WK_EXPORT bool WKBundlePageCanShowMIMEType(WKBundlePageRef, WKStringRef mimeType); > > WK_EXPORT void* WKAccessibilityRootObject(WKBundlePageRef); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index f0adc259ab0b11bf12877c6406e36534b985b2f7..a613a59755a19b7743e739c64ccf683d798c82a8 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,22 @@ >+2019-01-10 Timothy Hatcher <timothy@apple.com> >+ >+ Add WKBundlePage SPI to temporarily force light or dark appearance on a page. >+ https://bugs.webkit.org/show_bug.cgi?id=193327 >+ rdar://problem/47093222 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WebKit/mac/ForceLightAppearanceInBundle.mm: Added. >+ (TestWebKitAPI::didFinishNavigation): >+ (TestWebKitAPI::didReceiveMessageFromInjectedBundle): >+ (TestWebKitAPI::TEST): >+ * TestWebKitAPI/Tests/WebKit/mac/ForceLightAppearanceInBundle_Bundle.mm: Added. >+ (TestWebKitAPI::ForceLightAppearanceInBundleTest::ForceLightAppearanceInBundleTest): >+ (TestWebKitAPI::ForceLightAppearanceInBundleTest::didCreatePage): >+ (TestWebKitAPI::ForceLightAppearanceInBundleTest::didReceiveMessage): >+ * TestWebKitAPI/Tests/WebKit/mac/dark-mode.html: Added. >+ > 2019-01-10 Zhifei Fang <zhifei_fang@apple.com> > > Disable the run-jsc-stress-test remote host key check. >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 12d2a04aabeec19483c7caba35a7dbdb747f937a..fe27e4993725782621fef804fad076d8c0c55e97 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -72,6 +72,9 @@ > 1C7FEB20207C0F2E00D23278 /* BackgroundColor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C7FEB1F207C0F2D00D23278 /* BackgroundColor.mm */; }; > 1C9EB8411E380DA1005C6442 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */; }; > 1CAD1F861E5CE7DA00AF2C2C /* FontCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD1F851E5CE7DA00AF2C2C /* FontCache.cpp */; }; >+ 1CF59AE221E68925006E37EC /* ForceLightAppearanceInBundle_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CF59AE021E68925006E37EC /* ForceLightAppearanceInBundle_Bundle.mm */; }; >+ 1CF59AE321E68932006E37EC /* ForceLightAppearanceInBundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CF59ADF21E68925006E37EC /* ForceLightAppearanceInBundle.mm */; }; >+ 1CF59AE521E6977D006E37EC /* dark-mode.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1CF59AE421E696FB006E37EC /* dark-mode.html */; }; > 1F83571B1D3FFB2300E3967B /* WKBackForwardList.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */; }; > 26DF5A6315A2A27E003689C2 /* CancelLoadFromResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 26DF5A6115A2A22B003689C2 /* CancelLoadFromResourceLoadDelegate.html */; }; > 26F52EAD1828827B0023D412 /* geolocationGetCurrentPosition.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 26F52EAC1828820E0023D412 /* geolocationGetCurrentPosition.html */; }; >@@ -1043,6 +1046,7 @@ > 7AEAD4811E20122700416EFE /* CrossPartitionFileSchemeAccess.html in Copy Resources */, > F4AB578A1F65165400DB0DA1 /* custom-draggable-div.html in Copy Resources */, > 290F4275172A221C00939FF0 /* custom-protocol-sync-xhr.html in Copy Resources */, >+ 1CF59AE521E6977D006E37EC /* dark-mode.html in Copy Resources */, > F47DFB2621A878DF00021FB6 /* data-detectors.html in Copy Resources */, > F486B1D01F67952300F34BDD /* DataTransfer-setDragImage.html in Copy Resources */, > F457A9D6202D68AF00F7E9D5 /* DataTransfer.html in Copy Resources */, >@@ -1356,6 +1360,9 @@ > 1CAD1F851E5CE7DA00AF2C2C /* FontCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCache.cpp; sourceTree = "<group>"; }; > 1CB9BC371A67482300FE5678 /* WeakPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeakPtr.cpp; sourceTree = "<group>"; }; > 1CF0D3781BBF2F3D00B4EF54 /* WKRetainPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKRetainPtr.cpp; sourceTree = "<group>"; }; >+ 1CF59ADF21E68925006E37EC /* ForceLightAppearanceInBundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ForceLightAppearanceInBundle.mm; sourceTree = "<group>"; }; >+ 1CF59AE021E68925006E37EC /* ForceLightAppearanceInBundle_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ForceLightAppearanceInBundle_Bundle.mm; sourceTree = "<group>"; }; >+ 1CF59AE421E696FB006E37EC /* dark-mode.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "dark-mode.html"; sourceTree = "<group>"; }; > 1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKBackForwardList.mm; path = Tests/WebKit/WKBackForwardList.mm; sourceTree = SOURCE_ROOT; }; > 260BA5781B1D2E7B004FA07C /* DFACombiner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFACombiner.cpp; sourceTree = "<group>"; }; > 260BA57A1B1D2EE2004FA07C /* DFAHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFAHelpers.h; sourceTree = "<group>"; }; >@@ -3528,7 +3535,10 @@ > 7AC7B56F20D9BA5B002C09A0 /* CustomBundleObject.mm */, > 7AC7B56C20D9768F002C09A0 /* CustomBundleParameter.mm */, > 7AC7B56B20D9768E002C09A0 /* CustomBundleParameter_Bundle.mm */, >+ 1CF59AE421E696FB006E37EC /* dark-mode.html */, > BCAA485714A044D40088FAC4 /* EditorCommands.mm */, >+ 1CF59ADF21E68925006E37EC /* ForceLightAppearanceInBundle.mm */, >+ 1CF59AE021E68925006E37EC /* ForceLightAppearanceInBundle_Bundle.mm */, > C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */, > C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */, > 1AEF994817A09F5300998EF0 /* GetPIDAfterAbortedProcessLaunch.cpp */, >@@ -3995,6 +4005,7 @@ > 2E92B8FA2164A0C1005B64F0 /* FontAttributes.mm in Sources */, > 1CAD1F861E5CE7DA00AF2C2C /* FontCache.cpp in Sources */, > F456AB1C213EDBA300CB2CEF /* FontManagerTests.mm in Sources */, >+ 1CF59AE321E68932006E37EC /* ForceLightAppearanceInBundle.mm in Sources */, > 7CCE7EF51A411AE600447C4C /* ForceRepaint.cpp in Sources */, > 7CCE7EC01A411A7E00447C4C /* FragmentNavigation.mm in Sources */, > 376C8C061D6E197C007D2BB9 /* FrameHandle.cpp in Sources */, >@@ -4365,6 +4376,7 @@ > 51393E221523952D005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp in Sources */, > F6F49C6B15545CA70007F39D /* DOMWindowExtensionNoCache_Bundle.cpp in Sources */, > 1171B24F219F49CD00CB897D /* FirstMeaningfulPaintMilestone_Bundle.cpp in Sources */, >+ 1CF59AE221E68925006E37EC /* ForceLightAppearanceInBundle_Bundle.mm in Sources */, > C0C5D3C61459912900A802A6 /* GetBackingScaleFactor_Bundle.mm in Sources */, > F660AA1115A5F631003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp in Sources */, > 4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebKit/mac/ForceLightAppearanceInBundle.mm b/Tools/TestWebKitAPI/Tests/WebKit/mac/ForceLightAppearanceInBundle.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..6d95d3e432db17ec0d1993f0351705abe857ee58 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit/mac/ForceLightAppearanceInBundle.mm >@@ -0,0 +1,92 @@ >+/* >+ * Copyright (C) 2019 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/WKContextPrivate.h> >+ >+namespace TestWebKitAPI { >+ >+static bool didFinishLoad; >+static bool messageReceived; >+ >+static void didFinishNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*) >+{ >+ didFinishLoad = true; >+} >+ >+static void didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void*) >+{ >+ messageReceived = true; >+ >+ ASSERT_NOT_NULL(messageBody); >+ EXPECT_EQ(WKStringGetTypeID(), WKGetTypeID(messageBody)); >+ >+ WKStringRef messageBodyString = static_cast<WKStringRef>(messageBody); >+ >+ EXPECT_WK_STREQ("TestDone", messageName); >+ EXPECT_WK_STREQ("rgb(0, 0, 0)", messageBodyString); >+} >+ >+TEST(WebKit, ForceLightAppearanceInBundle) >+{ >+ WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("ForceLightAppearanceInBundleTest")); >+ >+ PlatformWebView webView(context.get()); >+ >+ [webView.platformView() setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]; >+ >+ WKPageNavigationClientV0 loaderClient; >+ memset(&loaderClient, 0, sizeof(loaderClient)); >+ >+ loaderClient.base.version = 0; >+ loaderClient.didFinishNavigation = didFinishNavigation; >+ >+ WKPageSetPageNavigationClient(webView.page(), &loaderClient.base); >+ >+ WKContextInjectedBundleClientV0 injectedBundleClient; >+ memset(&injectedBundleClient, 0, sizeof(injectedBundleClient)); >+ >+ injectedBundleClient.base.version = 0; >+ injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle; >+ >+ WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient.base); >+ >+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("dark-mode", "html")).get()); >+ Util::run(&didFinishLoad); >+ >+ WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("RunTest").get(), nullptr); >+ Util::run(&messageReceived); >+ messageReceived = false; >+} >+ >+} // namespace TestWebKitAPI >+ >+#endif >diff --git a/Tools/TestWebKitAPI/Tests/WebKit/mac/ForceLightAppearanceInBundle_Bundle.mm b/Tools/TestWebKitAPI/Tests/WebKit/mac/ForceLightAppearanceInBundle_Bundle.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..aeba1c348fbc66a170e539e0a7286aee9153e604 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit/mac/ForceLightAppearanceInBundle_Bundle.mm >@@ -0,0 +1,92 @@ >+/* >+ * Copyright (C) 2019 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 "PlatformUtilities.h" >+#include <JavaScriptCore/JSRetainPtr.h> >+#include <WebKit/WKBundleFrame.h> >+#include <WebKit/WKBundlePage.h> >+#include <WebKit/WKBundlePagePrivate.h> >+ >+namespace TestWebKitAPI { >+ >+class ForceLightAppearanceInBundleTest : public InjectedBundleTest { >+public: >+ ForceLightAppearanceInBundleTest(const std::string& identifier) >+ : InjectedBundleTest(identifier) >+ { >+ } >+ >+ virtual void didCreatePage(WKBundleRef bundle, WKBundlePageRef page) >+ { >+ m_page = page; >+ } >+ >+ virtual void didReceiveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody) >+ { >+ if (!WKStringIsEqualToUTF8CString(messageName, "RunTest")) >+ return; >+ >+ if (!WKBundlePageIsUsingDarkAppearance(m_page)) >+ WKBundlePostMessage(bundle, Util::toWK("TestFailed").get(), Util::toWK("Page isn't in dark mode at start of test.").get()); >+ >+ WKBundlePageSetUseDarkAppearance(m_page, false); >+ >+ if (WKBundlePageIsUsingDarkAppearance(m_page)) >+ WKBundlePostMessage(bundle, Util::toWK("TestFailed").get(), Util::toWK("Switching to light mode failed.").get()); >+ >+ auto mainFrame = WKBundlePageGetMainFrame(m_page); >+ auto scriptContext = WKBundleFrameGetJavaScriptContext(mainFrame); >+ auto script = adopt(JSStringCreateWithUTF8CString("window.getComputedStyle(document.body).getPropertyValue('color')")); >+ >+ auto result = JSEvaluateScript(scriptContext, script.get(), nullptr, nullptr, 0, nullptr); >+ auto resultString = adopt(JSValueToStringCopy(scriptContext, result, nullptr)); >+ >+ auto bufferSize = JSStringGetMaximumUTF8CStringSize(resultString.get()); >+ auto buffer = std::make_unique<char[]>(bufferSize); >+ JSStringGetUTF8CString(resultString.get(), buffer.get(), bufferSize); >+ >+ WKBundlePageSetUseDarkAppearance(m_page, true); >+ >+ if (!WKBundlePageIsUsingDarkAppearance(m_page)) >+ WKBundlePostMessage(bundle, Util::toWK("TestFailed").get(), Util::toWK("Switching back to dark mode failed.").get()); >+ >+ WKBundlePostMessage(bundle, Util::toWK("TestDone").get(), Util::toWK(buffer.get()).get()); >+ } >+ >+private: >+ WKBundlePageRef m_page { nullptr }; >+}; >+ >+static InjectedBundleTest::Register<ForceLightAppearanceInBundleTest> registrar("ForceLightAppearanceInBundleTest"); >+ >+} // namespace TestWebKitAPI >+ >+#endif >diff --git a/Tools/TestWebKitAPI/Tests/WebKit/mac/dark-mode.html b/Tools/TestWebKitAPI/Tests/WebKit/mac/dark-mode.html >new file mode 100644 >index 0000000000000000000000000000000000000000..83c23561e01ec6ae572117cc8a4997e53b5c8dca >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKit/mac/dark-mode.html >@@ -0,0 +1,5 @@ >+<style> >+:root { >+ supported-color-schemes: light dark; >+} >+</style>
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 193327
:
358808
|
358813
|
358818
|
358916