| Index: chrome/browser/web_bluetooth_browsertest.cc
|
| diff --git a/chrome/browser/web_bluetooth_browsertest.cc b/chrome/browser/web_bluetooth_browsertest.cc
|
| index 6a94ea45e64b0bea1cb48c004943d62d35cf5405..2692b61e4ee680e960b4086ce19babaeb84d85b2 100644
|
| --- a/chrome/browser/web_bluetooth_browsertest.cc
|
| +++ b/chrome/browser/web_bluetooth_browsertest.cc
|
| @@ -76,4 +76,32 @@ IN_PROC_BROWSER_TEST_F(WebBluetoothTest, KillSwitchShouldBlock) {
|
| testing::MatchesRegex("NotFoundError: .*globally disabled.*"));
|
| }
|
|
|
| +// Tests that using Finch field trial parameters for blacklist additions has
|
| +// the effect of rejecting requestDevice calls.
|
| +IN_PROC_BROWSER_TEST_F(WebBluetoothTest, BlacklistShouldBlock) {
|
| + // Fake the BluetoothAdapter to say it's present.
|
| + scoped_refptr<device::MockBluetoothAdapter> adapter =
|
| + new testing::NiceMock<device::MockBluetoothAdapter>;
|
| + EXPECT_CALL(*adapter, IsPresent()).WillRepeatedly(testing::Return(true));
|
| + device::BluetoothAdapterFactory::SetAdapterForTesting(adapter);
|
| +
|
| + std::map<std::string, std::string> params;
|
| + params["blacklist_additions"] = "ee01:e";
|
| + variations::AssociateVariationParams("WebBluetoothBlacklist", "TestGroup",
|
| + params);
|
| + base::FieldTrialList::CreateFieldTrial("WebBluetoothBlacklist", "TestGroup");
|
| +
|
| + std::string rejection;
|
| + EXPECT_TRUE(content::ExecuteScriptAndExtractString(
|
| + web_contents_,
|
| + "navigator.bluetooth.requestDevice({filters: [{services: [0xee01]}]})"
|
| + " .then(() => { domAutomationController.send('Success'); },"
|
| + " reason => {"
|
| + " domAutomationController.send(reason.name + ': ' + reason.message);"
|
| + " });",
|
| + &rejection));
|
| + EXPECT_THAT(rejection,
|
| + testing::MatchesRegex("SecurityError: .*blacklisted UUID.*"));
|
| +}
|
| +
|
| } // namespace
|
|
|