Changeset 258566 in webkit


Ignore:
Timestamp:
Mar 17, 2020 11:33:58 AM (4 years ago)
Author:
Chris Dumez
Message:

Use less sync IPC for ITP testRunner methods
https://bugs.webkit.org/show_bug.cgi?id=209184

Reviewed by Alex Christensen.

  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setStatisticsDebugMode):
(WTR::TestRunner::setStatisticsPrevalentResourceForDebugMode):
(WTR::TestRunner::setStatisticsLastSeen):
(WTR::TestRunner::setStatisticsMergeStatistic):
(WTR::TestRunner::setStatisticsPrevalentResource):
(WTR::TestRunner::setStatisticsVeryPrevalentResource):
(WTR::TestRunner::installStatisticsDidScanDataRecordsCallback):

  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/http/tests/storageAccess/aggregate-sorted-data-with-storage-access-database.html

    r253697 r258566  
    1919                        testRunner.dumpResourceLoadStatistics();
    2020                        testPassed(event.data.replace("PASS ", ""));
     21                        testRunner.setStatisticsShouldBlockThirdPartyCookies(false, function() {
     22                            setEnableFeature(false, finishJSTest);
     23                        });
    2124                    });
     25                    return;
    2226                } else
    2327                    testFailed(event.data.replace("FAIL ", ""));
  • trunk/LayoutTests/http/tests/storageAccess/aggregate-sorted-data-with-storage-access.html

    r253697 r258566  
    1818                        testRunner.dumpResourceLoadStatistics();
    1919                        testPassed(event.data.replace("PASS ", ""));
     20                        testRunner.setStatisticsShouldBlockThirdPartyCookies(false, function() {
     21                            setEnableFeature(false, finishJSTest);
     22                        });
    2023                    });
     24                    return;
    2125                } else
    2226                    testFailed(event.data.replace("FAIL ", ""));
  • trunk/Tools/ChangeLog

    r258562 r258566  
     12020-03-17  Chris Dumez  <cdumez@apple.com>
     2
     3        Use less sync IPC for ITP testRunner methods
     4        https://bugs.webkit.org/show_bug.cgi?id=209184
     5
     6        Reviewed by Alex Christensen.
     7
     8        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     9        (WTR::TestRunner::setStatisticsDebugMode):
     10        (WTR::TestRunner::setStatisticsPrevalentResourceForDebugMode):
     11        (WTR::TestRunner::setStatisticsLastSeen):
     12        (WTR::TestRunner::setStatisticsMergeStatistic):
     13        (WTR::TestRunner::setStatisticsPrevalentResource):
     14        (WTR::TestRunner::setStatisticsVeryPrevalentResource):
     15        (WTR::TestRunner::installStatisticsDidScanDataRecordsCallback):
     16        * WebKitTestRunner/TestInvocation.cpp:
     17        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
     18        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     19
    1202020-03-17  Chris Dumez  <cdumez@apple.com>
    221
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r258421 r258566  
    14361436    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetStatisticsDebugMode"));
    14371437    WKRetainPtr<WKBooleanRef> messageBody = adoptWK(WKBooleanCreate(value));
    1438     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1438    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
    14391439}
    14401440
     
    14501450    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetStatisticsPrevalentResourceForDebugMode"));
    14511451    WKRetainPtr<WKStringRef> messageBody = adoptWK(WKStringCreateWithJSString(hostName));
    1452     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1452    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
    14531453}
    14541454
     
    14821482    WKRetainPtr<WKDictionaryRef> messageBody = adoptWK(WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
    14831483   
    1484     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1484    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
    14851485}
    14861486
     
    15361536    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetStatisticsMergeStatistic"));
    15371537    WKRetainPtr<WKDictionaryRef> messageBody = adoptWK(WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
    1538     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1538    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
    15391539}
    15401540
     
    15701570    WKRetainPtr<WKDictionaryRef> messageBody = adoptWK(WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
    15711571
    1572     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1572    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
    15731573}
    15741574
     
    16041604    WKRetainPtr<WKDictionaryRef> messageBody = adoptWK(WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
    16051605   
    1606     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1606    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
    16071607}
    16081608
     
    20312031    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("StatisticsNotifyPagesWhenDataRecordsWereScanned"));
    20322032    WKRetainPtr<WKBooleanRef> messageBody = adoptWK(WKBooleanCreate(notifyPagesWhenDataRecordsWereScanned));
    2033     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     2033    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
    20342034}
    20352035
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r258421 r258566  
    826826    }
    827827
    828     ASSERT_NOT_REACHED();
    829 }
    830 
    831 WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
    832 {
    833     if (WKStringIsEqualToUTF8CString(messageName, "Initialization")) {
    834         auto settings = createTestSettingsDictionary();
    835         WKRetainPtr<WKStringRef> resumeTestingKey = adoptWK(WKStringCreateWithUTF8CString("ResumeTesting"));
    836         WKRetainPtr<WKBooleanRef> resumeTestingValue = adoptWK(WKBooleanCreate(m_startedTesting));
    837         WKDictionarySetItem(settings.get(), resumeTestingKey.get(), resumeTestingValue.get());
    838         return settings;
    839     }
    840 
    841     if (WKStringIsEqualToUTF8CString(messageName, "SetDumpPixels")) {
    842         ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
    843         m_dumpPixels = WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody));
    844         return nullptr;
    845     }
    846     if (WKStringIsEqualToUTF8CString(messageName, "GetDumpPixels"))
    847         return adoptWK(WKBooleanCreate(m_dumpPixels));
    848 
    849     if (WKStringIsEqualToUTF8CString(messageName, "SetWhatToDump")) {
    850         ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
    851         m_whatToDump = static_cast<WhatToDump>(WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody)));
    852         return nullptr;
    853     }
    854     if (WKStringIsEqualToUTF8CString(messageName, "GetWhatToDump"))
    855         return adoptWK(WKUInt64Create(static_cast<uint64_t>(m_whatToDump)));
    856 
    857     if (WKStringIsEqualToUTF8CString(messageName, "SetWaitUntilDone")) {
    858         ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
    859         setWaitUntilDone(static_cast<unsigned char>(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody))));
    860         return nullptr;
    861     }
    862     if (WKStringIsEqualToUTF8CString(messageName, "GetWaitUntilDone"))
    863         return adoptWK(WKBooleanCreate(m_waitUntilDone));
    864 
    865     if (WKStringIsEqualToUTF8CString(messageName, "SetDumpFrameLoadCallbacks")) {
    866         ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
    867         m_dumpFrameLoadCallbacks = static_cast<unsigned char>(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
    868         return nullptr;
    869     }
    870     if (WKStringIsEqualToUTF8CString(messageName, "GetDumpFrameLoadCallbacks"))
    871         return adoptWK(WKBooleanCreate(m_dumpFrameLoadCallbacks));
    872 
    873     if (WKStringIsEqualToUTF8CString(messageName, "SetCanOpenWindows")) {
    874         ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
    875         m_canOpenWindows = static_cast<unsigned char>(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
    876         return nullptr;
    877     }
    878 
    879     if (WKStringIsEqualToUTF8CString(messageName, "SetWindowIsKey")) {
    880         ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
    881         WKBooleanRef isKeyValue = static_cast<WKBooleanRef>(messageBody);
    882         TestController::singleton().mainWebView()->setWindowIsKey(WKBooleanGetValue(isKeyValue));
    883         return nullptr;
    884     }
    885 
    886     if (WKStringIsEqualToUTF8CString(messageName, "SetViewSize")) {
    887         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
    888 
    889         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
    890         WKRetainPtr<WKStringRef> widthKey = adoptWK(WKStringCreateWithUTF8CString("width"));
    891         WKRetainPtr<WKStringRef> heightKey = adoptWK(WKStringCreateWithUTF8CString("height"));
    892 
    893         WKDoubleRef widthWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, widthKey.get()));
    894         WKDoubleRef heightWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, heightKey.get()));
    895 
    896         TestController::singleton().mainWebView()->resizeTo(WKDoubleGetValue(widthWK), WKDoubleGetValue(heightWK));
    897         return nullptr;
    898     }
    899 
    900     if (WKStringIsEqualToUTF8CString(messageName, "IsGeolocationClientActive")) {
    901         bool isActive = TestController::singleton().isGeolocationProviderActive();
    902         WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(isActive));
    903         return result;
    904     }
    905 
    906     if (WKStringIsEqualToUTF8CString(messageName, "SetCacheModel")) {
    907         ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
    908         uint64_t model = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody));
    909         WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(TestController::defaultWebsiteDataStore(), model);
    910         return nullptr;
    911     }
    912 
    913     if (WKStringIsEqualToUTF8CString(messageName, "IsWorkQueueEmpty")) {
    914         bool isEmpty = TestController::singleton().workQueueManager().isWorkQueueEmpty();
    915         WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(isEmpty));
    916         return result;
    917     }
    918 
    919     if (WKStringIsEqualToUTF8CString(messageName, "DidReceiveServerRedirectForProvisionalNavigation")) {
    920         WKRetainPtr<WKBooleanRef> result = adoptWK(WKBooleanCreate(TestController::singleton().didReceiveServerRedirectForProvisionalNavigation()));
    921         return result;
    922     }
    923 
    924     if (WKStringIsEqualToUTF8CString(messageName, "ClearDidReceiveServerRedirectForProvisionalNavigation")) {
    925         TestController::singleton().clearDidReceiveServerRedirectForProvisionalNavigation();
    926         return nullptr;
    927     }
    928 
    929     if (WKStringIsEqualToUTF8CString(messageName, "SecureEventInputIsEnabled")) {
    930 #if PLATFORM(MAC) && !PLATFORM(IOS_FAMILY)
    931         WKRetainPtr<WKBooleanRef> result = adoptWK(WKBooleanCreate(IsSecureEventInputEnabled()));
    932 #else
    933         WKRetainPtr<WKBooleanRef> result = adoptWK(WKBooleanCreate(false));
    934 #endif
    935         return result;
    936     }
    937 
    938     if (WKStringIsEqualToUTF8CString(messageName, "SetCustomUserAgent")) {
    939         WKStringRef userAgent = static_cast<WKStringRef>(messageBody);
    940         WKPageSetCustomUserAgent(TestController::singleton().mainWebView()->page(), userAgent);
    941         return nullptr;
    942     }
    943 
    944     if (WKStringIsEqualToUTF8CString(messageName, "GetAllStorageAccessEntries")) {
    945         TestController::singleton().getAllStorageAccessEntries();
    946         return nullptr;
    947     }
    948 
    949     if (WKStringIsEqualToUTF8CString(messageName, "SetAllowsAnySSLCertificate")) {
    950         TestController::singleton().setAllowsAnySSLCertificate(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
    951         return nullptr;
    952     }
    953    
    954     if (WKStringIsEqualToUTF8CString(messageName, "SetShouldSwapToEphemeralSessionOnNextNavigation")) {
    955         TestController::singleton().setShouldSwapToEphemeralSessionOnNextNavigation(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
    956         return nullptr;
    957     }
    958    
    959     if (WKStringIsEqualToUTF8CString(messageName, "SetShouldSwapToDefaultSessionOnNextNavigation")) {
    960         TestController::singleton().setShouldSwapToDefaultSessionOnNextNavigation(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
    961         return nullptr;
    962     }
    963 
    964     if (WKStringIsEqualToUTF8CString(messageName, "ImageCountInGeneralPasteboard")) {
    965         unsigned count = TestController::singleton().imageCountInGeneralPasteboard();
    966         WKRetainPtr<WKUInt64Ref> result = adoptWK(WKUInt64Create(count));
    967         return result;
    968     }
    969    
    970     if (WKStringIsEqualToUTF8CString(messageName, "DeleteAllIndexedDatabases")) {
    971         WKWebsiteDataStoreRemoveAllIndexedDatabases(TestController::defaultWebsiteDataStore(), nullptr, { });
    972         return nullptr;
    973     }
    974 
    975     if (WKStringIsEqualToUTF8CString(messageName, "AddMockMediaDevice")) {
    976         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
    977 
    978         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
    979         WKRetainPtr<WKStringRef> persistentIDKey = adoptWK(WKStringCreateWithUTF8CString("PersistentID"));
    980         WKRetainPtr<WKStringRef> labelKey = adoptWK(WKStringCreateWithUTF8CString("Label"));
    981         WKRetainPtr<WKStringRef> typeKey = adoptWK(WKStringCreateWithUTF8CString("Type"));
    982 
    983         auto persistentID = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, persistentIDKey.get()));
    984         auto label = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, labelKey.get()));
    985         auto type = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, typeKey.get()));
    986 
    987         TestController::singleton().addMockMediaDevice(persistentID, label, type);
    988         return nullptr;
    989     }
    990 
    991     if (WKStringIsEqualToUTF8CString(messageName, "ClearMockMediaDevices")) {
    992         TestController::singleton().clearMockMediaDevices();
    993         return nullptr;
    994     }
    995 
    996     if (WKStringIsEqualToUTF8CString(messageName, "RemoveMockMediaDevice")) {
    997         WKStringRef persistentId = static_cast<WKStringRef>(messageBody);
    998 
    999         TestController::singleton().removeMockMediaDevice(persistentId);
    1000         return nullptr;
    1001     }
    1002 
    1003     if (WKStringIsEqualToUTF8CString(messageName, "ResetMockMediaDevices")) {
    1004         TestController::singleton().resetMockMediaDevices();
    1005         return nullptr;
    1006     }
    1007 
    1008     if (WKStringIsEqualToUTF8CString(messageName, "SetMockCameraOrientation")) {
    1009         TestController::singleton().setMockCameraOrientation(WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody)));
    1010         return nullptr;
    1011     }
    1012 
    1013     if (WKStringIsEqualToUTF8CString(messageName, "IsMockRealtimeMediaSourceCenterEnabled")) {
    1014         bool isMockRealtimeMediaSourceCenterEnabled = TestController::singleton().isMockRealtimeMediaSourceCenterEnabled();
    1015         return adoptWK(WKBooleanCreate(isMockRealtimeMediaSourceCenterEnabled));
    1016     }
    1017    
    1018     if (WKStringIsEqualToUTF8CString(messageName, "HasAppBoundSession")) {
    1019         bool hasAppBoundSession = TestController::singleton().hasAppBoundSession();
    1020         return adoptWK(WKBooleanCreate(hasAppBoundSession));
    1021     }
    1022 
    1023 #if PLATFORM(MAC)
    1024     if (WKStringIsEqualToUTF8CString(messageName, "ConnectMockGamepad")) {
    1025         ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
    1026 
    1027         uint64_t index = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody));
    1028         WebCoreTestSupport::connectMockGamepad(index);
    1029        
    1030         return nullptr;
    1031     }
    1032 
    1033     if (WKStringIsEqualToUTF8CString(messageName, "DisconnectMockGamepad")) {
    1034         ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
    1035 
    1036         uint64_t index = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody));
    1037         WebCoreTestSupport::disconnectMockGamepad(index);
    1038 
    1039         return nullptr;
    1040     }
    1041 
    1042     if (WKStringIsEqualToUTF8CString(messageName, "SetMockGamepadDetails")) {
    1043         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
    1044 
    1045         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
    1046         WKRetainPtr<WKStringRef> gamepadIndexKey = adoptWK(WKStringCreateWithUTF8CString("GamepadIndex"));
    1047         WKRetainPtr<WKStringRef> gamepadIDKey = adoptWK(WKStringCreateWithUTF8CString("GamepadID"));
    1048         WKRetainPtr<WKStringRef> mappingKey = adoptWK(WKStringCreateWithUTF8CString("Mapping"));
    1049         WKRetainPtr<WKStringRef> axisCountKey = adoptWK(WKStringCreateWithUTF8CString("AxisCount"));
    1050         WKRetainPtr<WKStringRef> buttonCountKey = adoptWK(WKStringCreateWithUTF8CString("ButtonCount"));
    1051 
    1052         WKUInt64Ref gamepadIndex = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, gamepadIndexKey.get()));
    1053         WKStringRef gamepadID = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, gamepadIDKey.get()));
    1054         WKStringRef mapping = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, mappingKey.get()));
    1055         WKUInt64Ref axisCount = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, axisCountKey.get()));
    1056         WKUInt64Ref buttonCount = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, buttonCountKey.get()));
    1057 
    1058         WebCoreTestSupport::setMockGamepadDetails(WKUInt64GetValue(gamepadIndex), toWTFString(gamepadID), toWTFString(mapping), WKUInt64GetValue(axisCount), WKUInt64GetValue(buttonCount));
    1059         return nullptr;
    1060     }
    1061 
    1062     if (WKStringIsEqualToUTF8CString(messageName, "SetMockGamepadAxisValue")) {
    1063         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
    1064 
    1065         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
    1066         WKRetainPtr<WKStringRef> gamepadIndexKey = adoptWK(WKStringCreateWithUTF8CString("GamepadIndex"));
    1067         WKRetainPtr<WKStringRef> axisIndexKey = adoptWK(WKStringCreateWithUTF8CString("AxisIndex"));
    1068         WKRetainPtr<WKStringRef> valueKey = adoptWK(WKStringCreateWithUTF8CString("Value"));
    1069 
    1070         WKUInt64Ref gamepadIndex = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, gamepadIndexKey.get()));
    1071         WKUInt64Ref axisIndex = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, axisIndexKey.get()));
    1072         WKDoubleRef value = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, valueKey.get()));
    1073 
    1074         WebCoreTestSupport::setMockGamepadAxisValue(WKUInt64GetValue(gamepadIndex), WKUInt64GetValue(axisIndex), WKDoubleGetValue(value));
    1075 
    1076         return nullptr;
    1077     }
    1078 
    1079     if (WKStringIsEqualToUTF8CString(messageName, "SetMockGamepadButtonValue")) {
    1080         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
    1081 
    1082         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
    1083         WKRetainPtr<WKStringRef> gamepadIndexKey = adoptWK(WKStringCreateWithUTF8CString("GamepadIndex"));
    1084         WKRetainPtr<WKStringRef> buttonIndexKey = adoptWK(WKStringCreateWithUTF8CString("ButtonIndex"));
    1085         WKRetainPtr<WKStringRef> valueKey = adoptWK(WKStringCreateWithUTF8CString("Value"));
    1086 
    1087         WKUInt64Ref gamepadIndex = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, gamepadIndexKey.get()));
    1088         WKUInt64Ref buttonIndex = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, buttonIndexKey.get()));
    1089         WKDoubleRef value = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, valueKey.get()));
    1090 
    1091         WebCoreTestSupport::setMockGamepadButtonValue(WKUInt64GetValue(gamepadIndex), WKUInt64GetValue(buttonIndex), WKDoubleGetValue(value));
    1092 
    1093         return nullptr;
    1094     }
    1095 #endif // PLATFORM(MAC)
    1096 
    1097     if (WKStringIsEqualToUTF8CString(messageName, "UserMediaPermissionRequestCountForOrigin")) {
    1098         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
    1099         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
    1100 
    1101         WKRetainPtr<WKStringRef> originKey = adoptWK(WKStringCreateWithUTF8CString("origin"));
    1102         WKStringRef originWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, originKey.get()));
    1103 
    1104         WKRetainPtr<WKStringRef> parentOriginKey = adoptWK(WKStringCreateWithUTF8CString("parentOrigin"));
    1105         WKStringRef parentOriginWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, parentOriginKey.get()));
    1106        
    1107         unsigned count = TestController::singleton().userMediaPermissionRequestCountForOrigin(originWK, parentOriginWK);
    1108         WKRetainPtr<WKUInt64Ref> result = adoptWK(WKUInt64Create(count));
    1109         return result;
    1110     }
    1111     if (WKStringIsEqualToUTF8CString(messageName, "IsDoingMediaCapture")) {
    1112         WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(TestController::singleton().isDoingMediaCapture()));
    1113         return result;
    1114     }
    1115 
    1116     if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsEnabled")) {
    1117         ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
    1118         WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
    1119         TestController::singleton().setStatisticsEnabled(WKBooleanGetValue(value));
    1120         return nullptr;
    1121     }
    1122 
    1123     if (WKStringIsEqualToUTF8CString(messageName, "IsStatisticsEphemeral")) {
    1124         bool isEphemeral = TestController::singleton().isStatisticsEphemeral();
    1125         WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(isEphemeral));
    1126         return result;
    1127     }
    1128 
    1129828    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsDebugMode")) {
    1130829        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
    1131830        WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
    1132831        TestController::singleton().setStatisticsDebugMode(WKBooleanGetValue(value));
    1133         return nullptr;
    1134     }
    1135    
     832        return;
     833    }
     834
    1136835    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsPrevalentResourceForDebugMode")) {
    1137836        ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
    1138837        WKStringRef hostName = static_cast<WKStringRef>(messageBody);
    1139838        TestController::singleton().setStatisticsPrevalentResourceForDebugMode(hostName);
    1140         return nullptr;
    1141     }
    1142    
     839        return;
     840    }
     841
    1143842    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsLastSeen")) {
    1144843        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
    1145        
     844
    1146845        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
    1147846        WKRetainPtr<WKStringRef> hostNameKey = adoptWK(WKStringCreateWithUTF8CString("HostName"));
    1148847        WKRetainPtr<WKStringRef> valueKey = adoptWK(WKStringCreateWithUTF8CString("Value"));
    1149        
     848
    1150849        WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
    1151850        WKDoubleRef value = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, valueKey.get()));
    1152        
     851
    1153852        TestController::singleton().setStatisticsLastSeen(hostName, WKDoubleGetValue(value));
    1154        
    1155         return nullptr;
    1156     }
    1157    
     853        return;
     854    }
     855
    1158856    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsMergeStatistic")) {
    1159857        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     
    1182880        WKBooleanRef isVeryPrevalent = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, isVeryPrevalentKey.get()));
    1183881        WKUInt64Ref dataRecordsRemoved = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, dataRecordsRemovedKey.get()));
    1184        
     882
    1185883        TestController::singleton().setStatisticsMergeStatistic(hostName, topFrameDomain1, topFrameDomain2, WKDoubleGetValue(lastSeen), WKBooleanGetValue(hadUserInteraction), WKDoubleGetValue(mostRecentUserInteraction), WKBooleanGetValue(isGrandfathered), WKBooleanGetValue(isPrevalent), WKBooleanGetValue(isVeryPrevalent), WKUInt64GetValue(dataRecordsRemoved));
    1186 
    1187         return nullptr;
    1188     }
    1189    
     884        return;
     885    }
     886
    1190887    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsPrevalentResource")) {
    1191888        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     
    1199896
    1200897        TestController::singleton().setStatisticsPrevalentResource(hostName, WKBooleanGetValue(value));
    1201         return nullptr;
     898        return;
    1202899    }
    1203900
    1204901    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsVeryPrevalentResource")) {
    1205902        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
    1206        
     903
    1207904        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
    1208905        WKRetainPtr<WKStringRef> hostNameKey = adoptWK(WKStringCreateWithUTF8CString("HostName"));
    1209906        WKRetainPtr<WKStringRef> valueKey = adoptWK(WKStringCreateWithUTF8CString("Value"));
    1210        
     907
    1211908        WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
    1212909        WKBooleanRef value = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, valueKey.get()));
    1213        
     910
    1214911        TestController::singleton().setStatisticsVeryPrevalentResource(hostName, WKBooleanGetValue(value));
    1215         return nullptr;
     912        return;
     913    }
     914
     915    if (WKStringIsEqualToUTF8CString(messageName, "StatisticsNotifyPagesWhenDataRecordsWereScanned")) {
     916        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
     917        WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
     918        TestController::singleton().setStatisticsNotifyPagesWhenDataRecordsWereScanned(WKBooleanGetValue(value));
     919        return;
     920    }
     921
     922    ASSERT_NOT_REACHED();
     923}
     924
     925WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
     926{
     927    if (WKStringIsEqualToUTF8CString(messageName, "Initialization")) {
     928        auto settings = createTestSettingsDictionary();
     929        WKRetainPtr<WKStringRef> resumeTestingKey = adoptWK(WKStringCreateWithUTF8CString("ResumeTesting"));
     930        WKRetainPtr<WKBooleanRef> resumeTestingValue = adoptWK(WKBooleanCreate(m_startedTesting));
     931        WKDictionarySetItem(settings.get(), resumeTestingKey.get(), resumeTestingValue.get());
     932        return settings;
     933    }
     934
     935    if (WKStringIsEqualToUTF8CString(messageName, "SetDumpPixels")) {
     936        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
     937        m_dumpPixels = WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody));
     938        return nullptr;
     939    }
     940    if (WKStringIsEqualToUTF8CString(messageName, "GetDumpPixels"))
     941        return adoptWK(WKBooleanCreate(m_dumpPixels));
     942
     943    if (WKStringIsEqualToUTF8CString(messageName, "SetWhatToDump")) {
     944        ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
     945        m_whatToDump = static_cast<WhatToDump>(WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody)));
     946        return nullptr;
     947    }
     948    if (WKStringIsEqualToUTF8CString(messageName, "GetWhatToDump"))
     949        return adoptWK(WKUInt64Create(static_cast<uint64_t>(m_whatToDump)));
     950
     951    if (WKStringIsEqualToUTF8CString(messageName, "SetWaitUntilDone")) {
     952        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
     953        setWaitUntilDone(static_cast<unsigned char>(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody))));
     954        return nullptr;
     955    }
     956    if (WKStringIsEqualToUTF8CString(messageName, "GetWaitUntilDone"))
     957        return adoptWK(WKBooleanCreate(m_waitUntilDone));
     958
     959    if (WKStringIsEqualToUTF8CString(messageName, "SetDumpFrameLoadCallbacks")) {
     960        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
     961        m_dumpFrameLoadCallbacks = static_cast<unsigned char>(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
     962        return nullptr;
     963    }
     964    if (WKStringIsEqualToUTF8CString(messageName, "GetDumpFrameLoadCallbacks"))
     965        return adoptWK(WKBooleanCreate(m_dumpFrameLoadCallbacks));
     966
     967    if (WKStringIsEqualToUTF8CString(messageName, "SetCanOpenWindows")) {
     968        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
     969        m_canOpenWindows = static_cast<unsigned char>(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
     970        return nullptr;
     971    }
     972
     973    if (WKStringIsEqualToUTF8CString(messageName, "SetWindowIsKey")) {
     974        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
     975        WKBooleanRef isKeyValue = static_cast<WKBooleanRef>(messageBody);
     976        TestController::singleton().mainWebView()->setWindowIsKey(WKBooleanGetValue(isKeyValue));
     977        return nullptr;
     978    }
     979
     980    if (WKStringIsEqualToUTF8CString(messageName, "SetViewSize")) {
     981        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     982
     983        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     984        WKRetainPtr<WKStringRef> widthKey = adoptWK(WKStringCreateWithUTF8CString("width"));
     985        WKRetainPtr<WKStringRef> heightKey = adoptWK(WKStringCreateWithUTF8CString("height"));
     986
     987        WKDoubleRef widthWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, widthKey.get()));
     988        WKDoubleRef heightWK = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, heightKey.get()));
     989
     990        TestController::singleton().mainWebView()->resizeTo(WKDoubleGetValue(widthWK), WKDoubleGetValue(heightWK));
     991        return nullptr;
     992    }
     993
     994    if (WKStringIsEqualToUTF8CString(messageName, "IsGeolocationClientActive")) {
     995        bool isActive = TestController::singleton().isGeolocationProviderActive();
     996        WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(isActive));
     997        return result;
     998    }
     999
     1000    if (WKStringIsEqualToUTF8CString(messageName, "SetCacheModel")) {
     1001        ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
     1002        uint64_t model = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody));
     1003        WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(TestController::defaultWebsiteDataStore(), model);
     1004        return nullptr;
     1005    }
     1006
     1007    if (WKStringIsEqualToUTF8CString(messageName, "IsWorkQueueEmpty")) {
     1008        bool isEmpty = TestController::singleton().workQueueManager().isWorkQueueEmpty();
     1009        WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(isEmpty));
     1010        return result;
     1011    }
     1012
     1013    if (WKStringIsEqualToUTF8CString(messageName, "DidReceiveServerRedirectForProvisionalNavigation")) {
     1014        WKRetainPtr<WKBooleanRef> result = adoptWK(WKBooleanCreate(TestController::singleton().didReceiveServerRedirectForProvisionalNavigation()));
     1015        return result;
     1016    }
     1017
     1018    if (WKStringIsEqualToUTF8CString(messageName, "ClearDidReceiveServerRedirectForProvisionalNavigation")) {
     1019        TestController::singleton().clearDidReceiveServerRedirectForProvisionalNavigation();
     1020        return nullptr;
     1021    }
     1022
     1023    if (WKStringIsEqualToUTF8CString(messageName, "SecureEventInputIsEnabled")) {
     1024#if PLATFORM(MAC) && !PLATFORM(IOS_FAMILY)
     1025        WKRetainPtr<WKBooleanRef> result = adoptWK(WKBooleanCreate(IsSecureEventInputEnabled()));
     1026#else
     1027        WKRetainPtr<WKBooleanRef> result = adoptWK(WKBooleanCreate(false));
     1028#endif
     1029        return result;
     1030    }
     1031
     1032    if (WKStringIsEqualToUTF8CString(messageName, "SetCustomUserAgent")) {
     1033        WKStringRef userAgent = static_cast<WKStringRef>(messageBody);
     1034        WKPageSetCustomUserAgent(TestController::singleton().mainWebView()->page(), userAgent);
     1035        return nullptr;
     1036    }
     1037
     1038    if (WKStringIsEqualToUTF8CString(messageName, "GetAllStorageAccessEntries")) {
     1039        TestController::singleton().getAllStorageAccessEntries();
     1040        return nullptr;
     1041    }
     1042
     1043    if (WKStringIsEqualToUTF8CString(messageName, "SetAllowsAnySSLCertificate")) {
     1044        TestController::singleton().setAllowsAnySSLCertificate(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
     1045        return nullptr;
     1046    }
     1047   
     1048    if (WKStringIsEqualToUTF8CString(messageName, "SetShouldSwapToEphemeralSessionOnNextNavigation")) {
     1049        TestController::singleton().setShouldSwapToEphemeralSessionOnNextNavigation(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
     1050        return nullptr;
     1051    }
     1052   
     1053    if (WKStringIsEqualToUTF8CString(messageName, "SetShouldSwapToDefaultSessionOnNextNavigation")) {
     1054        TestController::singleton().setShouldSwapToDefaultSessionOnNextNavigation(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
     1055        return nullptr;
     1056    }
     1057
     1058    if (WKStringIsEqualToUTF8CString(messageName, "ImageCountInGeneralPasteboard")) {
     1059        unsigned count = TestController::singleton().imageCountInGeneralPasteboard();
     1060        WKRetainPtr<WKUInt64Ref> result = adoptWK(WKUInt64Create(count));
     1061        return result;
     1062    }
     1063   
     1064    if (WKStringIsEqualToUTF8CString(messageName, "DeleteAllIndexedDatabases")) {
     1065        WKWebsiteDataStoreRemoveAllIndexedDatabases(TestController::defaultWebsiteDataStore(), nullptr, { });
     1066        return nullptr;
     1067    }
     1068
     1069    if (WKStringIsEqualToUTF8CString(messageName, "AddMockMediaDevice")) {
     1070        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     1071
     1072        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     1073        WKRetainPtr<WKStringRef> persistentIDKey = adoptWK(WKStringCreateWithUTF8CString("PersistentID"));
     1074        WKRetainPtr<WKStringRef> labelKey = adoptWK(WKStringCreateWithUTF8CString("Label"));
     1075        WKRetainPtr<WKStringRef> typeKey = adoptWK(WKStringCreateWithUTF8CString("Type"));
     1076
     1077        auto persistentID = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, persistentIDKey.get()));
     1078        auto label = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, labelKey.get()));
     1079        auto type = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, typeKey.get()));
     1080
     1081        TestController::singleton().addMockMediaDevice(persistentID, label, type);
     1082        return nullptr;
     1083    }
     1084
     1085    if (WKStringIsEqualToUTF8CString(messageName, "ClearMockMediaDevices")) {
     1086        TestController::singleton().clearMockMediaDevices();
     1087        return nullptr;
     1088    }
     1089
     1090    if (WKStringIsEqualToUTF8CString(messageName, "RemoveMockMediaDevice")) {
     1091        WKStringRef persistentId = static_cast<WKStringRef>(messageBody);
     1092
     1093        TestController::singleton().removeMockMediaDevice(persistentId);
     1094        return nullptr;
     1095    }
     1096
     1097    if (WKStringIsEqualToUTF8CString(messageName, "ResetMockMediaDevices")) {
     1098        TestController::singleton().resetMockMediaDevices();
     1099        return nullptr;
     1100    }
     1101
     1102    if (WKStringIsEqualToUTF8CString(messageName, "SetMockCameraOrientation")) {
     1103        TestController::singleton().setMockCameraOrientation(WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody)));
     1104        return nullptr;
     1105    }
     1106
     1107    if (WKStringIsEqualToUTF8CString(messageName, "IsMockRealtimeMediaSourceCenterEnabled")) {
     1108        bool isMockRealtimeMediaSourceCenterEnabled = TestController::singleton().isMockRealtimeMediaSourceCenterEnabled();
     1109        return adoptWK(WKBooleanCreate(isMockRealtimeMediaSourceCenterEnabled));
     1110    }
     1111   
     1112    if (WKStringIsEqualToUTF8CString(messageName, "HasAppBoundSession")) {
     1113        bool hasAppBoundSession = TestController::singleton().hasAppBoundSession();
     1114        return adoptWK(WKBooleanCreate(hasAppBoundSession));
     1115    }
     1116
     1117#if PLATFORM(MAC)
     1118    if (WKStringIsEqualToUTF8CString(messageName, "ConnectMockGamepad")) {
     1119        ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
     1120
     1121        uint64_t index = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody));
     1122        WebCoreTestSupport::connectMockGamepad(index);
     1123       
     1124        return nullptr;
     1125    }
     1126
     1127    if (WKStringIsEqualToUTF8CString(messageName, "DisconnectMockGamepad")) {
     1128        ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
     1129
     1130        uint64_t index = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody));
     1131        WebCoreTestSupport::disconnectMockGamepad(index);
     1132
     1133        return nullptr;
     1134    }
     1135
     1136    if (WKStringIsEqualToUTF8CString(messageName, "SetMockGamepadDetails")) {
     1137        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     1138
     1139        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     1140        WKRetainPtr<WKStringRef> gamepadIndexKey = adoptWK(WKStringCreateWithUTF8CString("GamepadIndex"));
     1141        WKRetainPtr<WKStringRef> gamepadIDKey = adoptWK(WKStringCreateWithUTF8CString("GamepadID"));
     1142        WKRetainPtr<WKStringRef> mappingKey = adoptWK(WKStringCreateWithUTF8CString("Mapping"));
     1143        WKRetainPtr<WKStringRef> axisCountKey = adoptWK(WKStringCreateWithUTF8CString("AxisCount"));
     1144        WKRetainPtr<WKStringRef> buttonCountKey = adoptWK(WKStringCreateWithUTF8CString("ButtonCount"));
     1145
     1146        WKUInt64Ref gamepadIndex = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, gamepadIndexKey.get()));
     1147        WKStringRef gamepadID = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, gamepadIDKey.get()));
     1148        WKStringRef mapping = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, mappingKey.get()));
     1149        WKUInt64Ref axisCount = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, axisCountKey.get()));
     1150        WKUInt64Ref buttonCount = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, buttonCountKey.get()));
     1151
     1152        WebCoreTestSupport::setMockGamepadDetails(WKUInt64GetValue(gamepadIndex), toWTFString(gamepadID), toWTFString(mapping), WKUInt64GetValue(axisCount), WKUInt64GetValue(buttonCount));
     1153        return nullptr;
     1154    }
     1155
     1156    if (WKStringIsEqualToUTF8CString(messageName, "SetMockGamepadAxisValue")) {
     1157        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     1158
     1159        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     1160        WKRetainPtr<WKStringRef> gamepadIndexKey = adoptWK(WKStringCreateWithUTF8CString("GamepadIndex"));
     1161        WKRetainPtr<WKStringRef> axisIndexKey = adoptWK(WKStringCreateWithUTF8CString("AxisIndex"));
     1162        WKRetainPtr<WKStringRef> valueKey = adoptWK(WKStringCreateWithUTF8CString("Value"));
     1163
     1164        WKUInt64Ref gamepadIndex = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, gamepadIndexKey.get()));
     1165        WKUInt64Ref axisIndex = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, axisIndexKey.get()));
     1166        WKDoubleRef value = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, valueKey.get()));
     1167
     1168        WebCoreTestSupport::setMockGamepadAxisValue(WKUInt64GetValue(gamepadIndex), WKUInt64GetValue(axisIndex), WKDoubleGetValue(value));
     1169
     1170        return nullptr;
     1171    }
     1172
     1173    if (WKStringIsEqualToUTF8CString(messageName, "SetMockGamepadButtonValue")) {
     1174        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     1175
     1176        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     1177        WKRetainPtr<WKStringRef> gamepadIndexKey = adoptWK(WKStringCreateWithUTF8CString("GamepadIndex"));
     1178        WKRetainPtr<WKStringRef> buttonIndexKey = adoptWK(WKStringCreateWithUTF8CString("ButtonIndex"));
     1179        WKRetainPtr<WKStringRef> valueKey = adoptWK(WKStringCreateWithUTF8CString("Value"));
     1180
     1181        WKUInt64Ref gamepadIndex = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, gamepadIndexKey.get()));
     1182        WKUInt64Ref buttonIndex = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, buttonIndexKey.get()));
     1183        WKDoubleRef value = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, valueKey.get()));
     1184
     1185        WebCoreTestSupport::setMockGamepadButtonValue(WKUInt64GetValue(gamepadIndex), WKUInt64GetValue(buttonIndex), WKDoubleGetValue(value));
     1186
     1187        return nullptr;
     1188    }
     1189#endif // PLATFORM(MAC)
     1190
     1191    if (WKStringIsEqualToUTF8CString(messageName, "UserMediaPermissionRequestCountForOrigin")) {
     1192        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     1193        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     1194
     1195        WKRetainPtr<WKStringRef> originKey = adoptWK(WKStringCreateWithUTF8CString("origin"));
     1196        WKStringRef originWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, originKey.get()));
     1197
     1198        WKRetainPtr<WKStringRef> parentOriginKey = adoptWK(WKStringCreateWithUTF8CString("parentOrigin"));
     1199        WKStringRef parentOriginWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, parentOriginKey.get()));
     1200       
     1201        unsigned count = TestController::singleton().userMediaPermissionRequestCountForOrigin(originWK, parentOriginWK);
     1202        WKRetainPtr<WKUInt64Ref> result = adoptWK(WKUInt64Create(count));
     1203        return result;
     1204    }
     1205    if (WKStringIsEqualToUTF8CString(messageName, "IsDoingMediaCapture")) {
     1206        WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(TestController::singleton().isDoingMediaCapture()));
     1207        return result;
     1208    }
     1209
     1210    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsEnabled")) {
     1211        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
     1212        WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
     1213        TestController::singleton().setStatisticsEnabled(WKBooleanGetValue(value));
     1214        return nullptr;
     1215    }
     1216
     1217    if (WKStringIsEqualToUTF8CString(messageName, "IsStatisticsEphemeral")) {
     1218        bool isEphemeral = TestController::singleton().isStatisticsEphemeral();
     1219        WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(isEphemeral));
     1220        return result;
    12161221    }
    12171222   
     
    14711476        return nullptr;
    14721477    }
    1473    
     1478
    14741479    if (WKStringIsEqualToUTF8CString(messageName, "StatisticsNotifyPagesWhenDataRecordsWereScanned")) {
    14751480        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
Note: See TracChangeset for help on using the changeset viewer.