Commit da055314 authored by Findit's avatar Findit

Revert "CookieStore: Remove matchType"

This reverts commit 612ba1ba.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 805855 as the
culprit for failures in the build cycles as shown on:
https://analysis.chromium.org/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzYxMmJhMWJhZTc3M2VkMmY0OGUwY2M3Y2FhMDI5ZTM3MWFjZjRlMDIM

Sample Failed Build: https://ci.chromium.org/b/8869520836042840528

Sample Failed Step: compile

Original change's description:
> CookieStore: Remove matchType
> 
> This change removes matchType option from CookieStoreGetOptions.
> This decision has been discussed here [1], and will
> be revisited after launch to re-evaluate if the option
> is good to have or if we should do a full cleanup of
> the option.
> 
> [1] https://github.com/WICG/cookie-store/issues/128
> 
> Bug: 1124497
> Change-Id: I845c6e872aa25d138114ccf0b0a74332adeb650d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2402132
> Commit-Queue: Ayu Ishii <ayui@chromium.org>
> Reviewed-by: Victor Costan <pwnall@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#805855}


Change-Id: I34db3d51b56ed808b6b8df3c2e09ac8e659e57f4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1124497
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404780
Cr-Commit-Position: refs/heads/master@{#805869}
parent 84a07502
......@@ -12,6 +12,8 @@ blink_modules_sources("cookie_store") {
"cookie_store.h",
"cookie_store_manager.cc",
"cookie_store_manager.h",
"cookie_store_metrics.cc",
"cookie_store_metrics.h",
"extendable_cookie_change_event.cc",
"extendable_cookie_change_event.h",
"global_cookie_store.cc",
......
......@@ -18,6 +18,7 @@
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/modules/cookie_store/cookie_change_event.h"
#include "third_party/blink/renderer/modules/cookie_store/cookie_store_metrics.h"
#include "third_party/blink/renderer/modules/event_modules.h"
#include "third_party/blink/renderer/modules/event_target_modules.h"
#include "third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h"
......@@ -43,8 +44,13 @@ network::mojom::blink::CookieManagerGetOptionsPtr ToBackendOptions(
ExceptionState& exception_state) {
auto backend_options = network::mojom::blink::CookieManagerGetOptions::New();
// TODO(crbug.com/1124499): Cleanup matchType after evaluation.
backend_options->match_type = network::mojom::blink::CookieMatchType::EQUALS;
if (options->hasMatchType() && options->matchType() == "starts-with") {
backend_options->match_type =
network::mojom::blink::CookieMatchType::STARTS_WITH;
} else {
backend_options->match_type =
network::mojom::blink::CookieMatchType::EQUALS;
}
if (options->hasName()) {
backend_options->name = options->name();
......@@ -254,6 +260,7 @@ ScriptPromise CookieStore::getAll(ScriptState* script_state,
ExceptionState& exception_state) {
UseCounter::Count(CurrentExecutionContext(script_state->GetIsolate()),
WebFeature::kCookieStoreAPI);
RecordMatchType(*options);
return DoRead(script_state, options, &CookieStore::GetAllForUrlToGetAllResult,
exception_state);
......@@ -272,6 +279,7 @@ ScriptPromise CookieStore::get(ScriptState* script_state,
ExceptionState& exception_state) {
UseCounter::Count(CurrentExecutionContext(script_state->GetIsolate()),
WebFeature::kCookieStoreAPI);
RecordMatchType(*options);
return DoRead(script_state, options, &CookieStore::GetAllForUrlToGetResult,
exception_state);
......
......@@ -4,7 +4,15 @@
// https://github.com/WICG/async-cookies-api/blob/gh-pages/explainer.md
enum CookieMatchType {
"equals",
"starts-with"
};
dictionary CookieStoreGetOptions {
USVString name;
USVString url;
// TODO(ayui): Add default value "equals" back once we are done measuring
// usage.
CookieMatchType matchType;
};
......@@ -16,6 +16,7 @@
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/modules/cookie_store/cookie_change_event.h"
#include "third_party/blink/renderer/modules/cookie_store/cookie_store_metrics.h"
#include "third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h"
#include "third_party/blink/renderer/modules/service_worker/service_worker_registration.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
......@@ -50,9 +51,14 @@ mojom::blink::CookieChangeSubscriptionPtr ToBackendSubscription(
backend_subscription->url = default_cookie_url;
}
// TODO(crbug.com/1124499): Cleanup matchType after re-evaluation.
backend_subscription->match_type =
network::mojom::blink::CookieMatchType::EQUALS;
if (subscription->hasMatchType() &&
subscription->matchType() == "starts-with") {
backend_subscription->match_type =
network::mojom::blink::CookieMatchType::STARTS_WITH;
} else {
backend_subscription->match_type =
network::mojom::blink::CookieMatchType::EQUALS;
}
if (subscription->hasName()) {
backend_subscription->name = subscription->name();
......@@ -72,8 +78,20 @@ CookieStoreGetOptions* ToCookieChangeSubscription(
CookieStoreGetOptions* subscription = CookieStoreGetOptions::Create();
subscription->setUrl(backend_subscription.url);
if (!backend_subscription.name.IsEmpty())
if (backend_subscription.match_type !=
network::mojom::blink::CookieMatchType::STARTS_WITH ||
!backend_subscription.name.IsEmpty()) {
subscription->setName(backend_subscription.name);
}
switch (backend_subscription.match_type) {
case network::mojom::blink::CookieMatchType::STARTS_WITH:
subscription->setMatchType(WTF::String("starts-with"));
break;
case network::mojom::blink::CookieMatchType::EQUALS:
subscription->setMatchType(WTF::String("equals"));
break;
}
return subscription;
}
......@@ -103,6 +121,7 @@ ScriptPromise CookieStoreManager::subscribe(
Vector<mojom::blink::CookieChangeSubscriptionPtr> backend_subscriptions;
backend_subscriptions.ReserveInitialCapacity(subscriptions.size());
for (const CookieStoreGetOptions* subscription : subscriptions) {
RecordMatchType(*subscription);
mojom::blink::CookieChangeSubscriptionPtr backend_subscription =
ToBackendSubscription(default_cookie_url_, subscription,
exception_state);
......@@ -128,6 +147,7 @@ ScriptPromise CookieStoreManager::unsubscribe(
Vector<mojom::blink::CookieChangeSubscriptionPtr> backend_subscriptions;
backend_subscriptions.ReserveInitialCapacity(subscriptions.size());
for (const CookieStoreGetOptions* subscription : subscriptions) {
RecordMatchType(*subscription);
mojom::blink::CookieChangeSubscriptionPtr backend_subscription =
ToBackendSubscription(default_cookie_url_, subscription,
exception_state);
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/cookie_store/cookie_store_metrics.h"
#include "base/metrics/histogram_macros.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_cookie_store_get_options.h"
namespace blink {
// This enum describes the MatchType value specified by the user.
enum class MatchTypeOption {
// Do not change the meaning or ordering of these values because they are
// being recorded in a UMA metric.
kUnspecified = 0,
kEquals = 1,
kStartsWith = 2,
kMaxValue = kStartsWith,
};
void RecordMatchType(const CookieStoreGetOptions& options) {
MatchTypeOption uma_match_type;
// TODO(crbug.com/1092328): Switch by V8CookieMatchType::Enum.
if (!options.hasMatchType()) {
uma_match_type = MatchTypeOption::kUnspecified;
} else if (options.matchType() == "equals") {
uma_match_type = MatchTypeOption::kEquals;
} else if (options.matchType() == "starts-with") {
uma_match_type = MatchTypeOption::kStartsWith;
} else {
NOTREACHED();
// In case of an invalid value, we assume it's "equals" for the consistency
// of UMA.
uma_match_type = MatchTypeOption::kEquals;
}
UMA_HISTOGRAM_ENUMERATION("Blink.CookieStore.MatchType", uma_match_type);
}
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_COOKIE_STORE_COOKIE_STORE_METRICS_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_COOKIE_STORE_COOKIE_STORE_METRICS_H_
namespace blink {
class CookieStoreGetOptions;
// Record explicitly set MatchType option with UMA.
void RecordMatchType(const CookieStoreGetOptions& options);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_COOKIE_STORE_COOKIE_STORE_METRICS_H_
......@@ -39,7 +39,9 @@ promise_test(async testCase => {
}
{
const subscriptions = [{ name: 'cookie-name1', url: `${scope}/path1` }];
const subscriptions = [
{ name: 'cookie-name1', matchType: 'equals', url: `${scope}/path1` },
];
await registration.cookies.subscribe(subscriptions);
testCase.add_cleanup(() => {
// For non-ServiceWorker environments, registration.unregister() cleans up
......@@ -52,7 +54,7 @@ promise_test(async testCase => {
{
const subscriptions = [
{ }, // Test the default values for subscription properties.
{ name: 'cookie-prefix' },
{ name: 'cookie-prefix', matchType: 'starts-with' },
];
await registration.cookies.subscribe(subscriptions);
testCase.add_cleanup(() => {
......@@ -70,8 +72,11 @@ promise_test(async testCase => {
subscriptions.sort((a, b) => CompareStrings(`${a.name}`, `${b.name}`));
assert_equals(subscriptions[0].name, 'cookie-name1');
assert_equals('equals', subscriptions[0].matchType);
assert_equals(subscriptions[1].name, 'cookie-prefix');
assert_equals('starts-with', subscriptions[1].matchType);
assert_false('name' in subscriptions[2]);
assert_equals('starts-with', subscriptions[2].matchType);
}, 'getSubscriptions returns a subscription passed to subscribe');
......@@ -30,7 +30,9 @@ promise_test(async testCase => {
}
{
const subscriptions = [{ name: 'cookie-name', url: `${scope}/path` }];
const subscriptions = [
{ name: 'cookie-name', matchType: 'equals', url: `${scope}/path` }
];
await registration.cookies.subscribe(subscriptions);
testCase.add_cleanup(() => {
// For non-ServiceWorker environments, registration.unregister() cleans up
......@@ -45,6 +47,7 @@ promise_test(async testCase => {
assert_equals(subscriptions.length, 1);
assert_equals(subscriptions[0].name, 'cookie-name');
assert_equals(subscriptions[0].matchType, 'equals');
assert_equals(subscriptions[0].url,
(new URL(`${scope}/path`, self.location.href)).href);
}, 'getSubscriptions returns a subscription passed to subscribe');
......@@ -32,14 +32,11 @@ promise_test(async testCase => {
await cookieStore.delete('cookie-name-2');
});
const cookies = await cookieStore.getAll({});
cookies.sort((a, b) => a.name.localeCompare(b.name));
assert_equals(cookies.length, 2);
const cookies = await cookieStore.getAll('cookie-name');
assert_equals(cookies.length, 1);
assert_equals(cookies[0].name, 'cookie-name');
assert_equals(cookies[0].value, 'cookie-value');
assert_equals(cookies[1].name, 'cookie-name-2');
assert_equals(cookies[1].value, 'cookie-value-2');
}, 'cookieStore.getAll with empty options');
}, 'cookieStore.getAll with positional name');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
......@@ -51,11 +48,11 @@ promise_test(async testCase => {
await cookieStore.delete('cookie-name-2');
});
const cookies = await cookieStore.getAll('cookie-name');
const cookies = await cookieStore.getAll({ name: 'cookie-name' });
assert_equals(cookies.length, 1);
assert_equals(cookies[0].name, 'cookie-name');
assert_equals(cookies[0].value, 'cookie-value');
}, 'cookieStore.getAll with positional name');
}, 'cookieStore.getAll with name in options');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
......@@ -67,11 +64,29 @@ promise_test(async testCase => {
await cookieStore.delete('cookie-name-2');
});
const cookies = await cookieStore.getAll({ name: 'cookie-name' });
const cookies = await cookieStore.getAll('cookie-name',
{ name: 'wrong-cookie-name' });
assert_equals(cookies.length, 1);
assert_equals(cookies[0].name, 'cookie-name');
assert_equals(cookies[0].value, 'cookie-value');
}, 'cookieStore.getAll with name in options');
}, 'cookieStore.getAll with name in both positional arguments and options');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
testCase.add_cleanup(async () => {
await cookieStore.delete('cookie-name');
});
const cookies = await cookieStore.getAll({ name: 'cookie-name',
matchType: 'equals' });
assert_equals(cookies.length, 1);
assert_equals(cookies[0].name, 'cookie-name');
assert_equals(cookies[0].value, 'cookie-value');
const no_cookies = await cookieStore.getAll(
'cookie-na', { matchType: 'equals' });
assert_equals(no_cookies.length, 0);
}, 'cookieStore.getAll with matchType explicitly set to equals');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
......@@ -83,12 +98,50 @@ promise_test(async testCase => {
await cookieStore.delete('cookie-name-2');
});
const cookies = await cookieStore.getAll('cookie-name',
{ name: 'wrong-cookie-name' });
const cookies = await cookieStore.getAll({ name: 'cookie-name-',
matchType: 'starts-with' });
assert_equals(cookies.length, 1);
assert_equals(cookies[0].name, 'cookie-name-2');
assert_equals(cookies[0].value, 'cookie-value-2');
}, 'cookieStore.getAll with matchType set to starts-with');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
testCase.add_cleanup(async () => {
await cookieStore.delete('cookie-name');
});
await cookieStore.set('cookie-name-2', 'cookie-value-2');
testCase.add_cleanup(async () => {
await cookieStore.delete('cookie-name-2');
});
await promise_rejects_js(testCase, TypeError, cookieStore.getAll(
{ name: 'cookie-name', matchType: 'invalid' }));
}, 'cookieStore.getAll with invalid matchType');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
testCase.add_cleanup(async () => {
await cookieStore.delete('cookie-name');
});
const cookies = await cookieStore.getAll({ matchType: 'equals' });
assert_equals(cookies.length, 1);
assert_equals(cookies[0].name, 'cookie-name');
assert_equals(cookies[0].value, 'cookie-value');
}, 'cookieStore.getAll with name in both positional arguments and options');
}, 'cookieStore.getAll with matchType set to equals and missing name');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
testCase.add_cleanup(async () => {
await cookieStore.delete('cookie-name');
});
const cookies = await cookieStore.getAll({ matchType: 'starts-with' });
assert_equals(cookies.length, 1);
assert_equals(cookies[0].name, 'cookie-name');
assert_equals(cookies[0].value, 'cookie-value');
}, 'cookieStore.getAll with matchType set to starts-with and missing name');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
......
......@@ -35,25 +35,33 @@ promise_test(async testCase => {
await cookieStore.delete('cookie-name');
});
const cookie = await cookieStore.get({});
const cookie = await cookieStore.get('cookie-name');
assert_equals(cookie.name, 'cookie-name');
assert_equals(cookie.value, 'cookie-value');
}, 'cookieStore.get with empty options');
}, 'cookieStore.get with positional name');
promise_test(async testCase => {
await cookieStore.set('cookie-name-1', 'cookie-value-1');
await cookieStore.set('cookie-name', 'cookie-value');
testCase.add_cleanup(async () => {
await cookieStore.delete('cookie-name-1');
await cookieStore.delete('cookie-name');
});
await cookieStore.set('cookie-name-2', 'cookie-value-2');
const cookie = await cookieStore.get({ name: 'cookie-name' });
assert_equals(cookie.name, 'cookie-name');
assert_equals(cookie.value, 'cookie-value');
}, 'cookieStore.get with name in options');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
testCase.add_cleanup(async () => {
await cookieStore.delete('cookie-name-2');
await cookieStore.delete('cookie-name');
});
const cookie = await cookieStore.get({});
assert_equals(cookie.name, 'cookie-name-1');
assert_equals(cookie.value, 'cookie-value-1');
},'cookieStore.get with empty options and multiple matches');
const cookie = await cookieStore.get('cookie-name',
{ name: 'wrong-cookie-name' });
assert_equals(cookie.name, 'cookie-name');
assert_equals(cookie.value, 'cookie-value');
}, 'cookieStore.get with name in both positional arguments and options');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
......@@ -61,10 +69,15 @@ promise_test(async testCase => {
await cookieStore.delete('cookie-name');
});
const cookie = await cookieStore.get('cookie-name');
const cookie = await cookieStore.get(
'cookie-name', { matchType: 'equals' });
assert_equals(cookie.name, 'cookie-name');
assert_equals(cookie.value, 'cookie-value');
}, 'cookieStore.get with positional name');
const no_cookie = await cookieStore.get({ name: 'cookie-na',
matchType: 'equals' });
assert_equals(no_cookie, null);
}, 'cookieStore.get with matchType explicitly set to equals');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
......@@ -72,10 +85,11 @@ promise_test(async testCase => {
await cookieStore.delete('cookie-name');
});
const cookie = await cookieStore.get({ name: 'cookie-name' });
const cookie = await cookieStore.get({ name: 'cookie-na',
matchType: 'starts-with' });
assert_equals(cookie.name, 'cookie-name');
assert_equals(cookie.value, 'cookie-value');
}, 'cookieStore.get with name in options');
}, 'cookieStore.get with matchType set to starts-with');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
......@@ -83,11 +97,31 @@ promise_test(async testCase => {
await cookieStore.delete('cookie-name');
});
const cookie = await cookieStore.get('cookie-name',
{ name: 'wrong-cookie-name' });
await promise_rejects_js(testCase, TypeError, cookieStore.get(
{ name: 'cookie-name', matchType: 'invalid' }));
}, 'cookieStore.get with invalid matchType');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
testCase.add_cleanup(async () => {
await cookieStore.delete('cookie-name');
});
const cookie = await cookieStore.get({ matchType: 'equals' });
assert_equals(cookie.name, 'cookie-name');
assert_equals(cookie.value, 'cookie-value');
}, 'cookieStore.get with name in both positional arguments and options');
}, 'cookieStore.get with matchType set to equals and missing name');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
testCase.add_cleanup(async () => {
await cookieStore.delete('cookie-name');
});
const cookie = await cookieStore.get({ matchType: 'starts-with' });
assert_equals(cookie.name, 'cookie-name');
assert_equals(cookie.value, 'cookie-value');
}, 'cookieStore.get with matchType set to starts-with and missing name');
promise_test(async testCase => {
await cookieStore.set('cookie-name', 'cookie-value');
......
......@@ -25,7 +25,9 @@ promise_test(async testCase => {
}
{
const subscriptions = [{ name: 'cookie-name' }];
const subscriptions = [
{ name: 'cookie-name', matchType: 'equals' }
];
await self.registration.cookies.subscribe(subscriptions);
testCase.add_cleanup(() => registration.cookies.unsubscribe(subscriptions));
}
......@@ -34,6 +36,7 @@ promise_test(async testCase => {
assert_equals(subscriptions.length, 1);
assert_equals(subscriptions[0].name, 'cookie-name');
assert_equals(subscriptions[0].matchType, 'equals');
assert_equals(subscriptions[0].url, registration.scope);
}, 'cookieStore.subscribe without url in option');
......@@ -59,7 +62,7 @@ promise_test(async testCase => {
await promise_rejects_js(testCase, TypeError,
registration.cookies.subscribe(
{ name: 'cookie-name', url: '/wrong/path' }));
{ name: 'cookie-name', matchType: 'equals', url: '/wrong/path' }));
}, 'cookieStore.subscribe with invalid url path in option');
promise_test(async testCase => {
......@@ -83,7 +86,9 @@ promise_test(async testCase => {
}
{
const subscriptions = [{ name: 'cookie-name' }];
const subscriptions = [
{ name: 'cookie-name', matchType: 'equals' }
];
// Call subscribe for same subscription multiple times to verify that it is
// idempotent.
await self.registration.cookies.subscribe(subscriptions);
......@@ -96,6 +101,7 @@ promise_test(async testCase => {
assert_equals(subscriptions.length, 1);
assert_equals(subscriptions[0].name, 'cookie-name');
assert_equals(subscriptions[0].matchType, 'equals');
assert_equals(subscriptions[0].url, registration.scope);
}, 'cookieStore.subscribe is idempotent');
......@@ -121,8 +127,8 @@ promise_test(async testCase => {
{
const subscriptions = [
{ name: 'cookie-name1' },
{ name: 'cookie-name2' },
{ name: 'cookie-name1', matchType: 'equals' },
{ name: 'cookie-name2', matchType: 'equals' }
];
await self.registration.cookies.subscribe(subscriptions);
testCase.add_cleanup(() => registration.cookies.unsubscribe(subscriptions));
......@@ -138,5 +144,6 @@ promise_test(async testCase => {
assert_equals(subscriptions.length, 1);
assert_equals(subscriptions[0].name, 'cookie-name2');
assert_equals(subscriptions[0].matchType, 'equals');
assert_equals(subscriptions[0].url, registration.scope);
}, 'CookieStore.unsubscribe is idempotent');
......@@ -16,7 +16,7 @@ promise_test(async t => {
t.add_cleanup(() => registration.unregister());
await wait_for_state(t, registration.installing, 'activated');
await registration.cookies.subscribe(
[{ name: 'cookie-name' }]);
[{ name: 'cookie-name', matchType: 'equals' }]);
const original_subscriptions = await registration.cookies.getSubscriptions();
assert_equals(original_subscriptions.length, 1,
'subscription count before unregistration');
......@@ -39,7 +39,7 @@ promise_test(async t => {
t.add_cleanup(() => registration.unregister());
await wait_for_state(t, registration.installing, 'activated');
await registration.cookies.subscribe(
[{ name: 'cookie-name' }]);
[{ name: 'cookie-name', matchType: 'equals' }]);
const original_subscriptions = await registration.cookies.getSubscriptions();
assert_equals(original_subscriptions.length, 1,
'subscription count before update');
......
......@@ -20,7 +20,9 @@ const kCookieChangeReceivedPromise = new Promise((resolve) => {
promise_test(async testCase => {
await kServiceWorkerActivatedPromise;
const subscriptions = [{ name: 'cookie-name', url: `${kScope}/path` }];
const subscriptions = [
{ name: 'cookie-name', matchType: 'equals', url: `${kScope}/path` },
];
await registration.cookies.subscribe(subscriptions);
testCase.add_cleanup(() => registration.cookies.unsubscribe(subscriptions));
......
......@@ -34,14 +34,16 @@ promise_test(async testCase => {
await kServiceWorkerActivatedPromise;
{
const subscriptions = [{ name: 'cookie-name1', url: `${kScope}/path1` }];
const subscriptions = [
{ name: 'cookie-name1', matchType: 'equals', url: `${kScope}/path1` },
];
await registration.cookies.subscribe(subscriptions);
testCase.add_cleanup(() => registration.cookies.unsubscribe(subscriptions));
}
{
const subscriptions = [
{ }, // Test the default values for subscription properties.
{ name: 'cookie-name2' },
{ name: 'cookie-prefix', matchType: 'starts-with' },
];
await registration.cookies.subscribe(subscriptions);
testCase.add_cleanup(() => registration.cookies.unsubscribe(subscriptions));
......
......@@ -35,8 +35,8 @@ promise_test(async testCase => {
await kServiceWorkerActivatedPromise;
const subscriptions = [
{ name: 'cookie-name' },
{ url: `${kScope}/path` }
{ name: 'coo', matchType: 'starts-with' },
{ name: 'cookie', matchType: 'starts-with' },
];
await registration.cookies.subscribe(subscriptions);
testCase.add_cleanup(() => registration.cookies.unsubscribe(subscriptions));
......
......@@ -18,7 +18,9 @@ const kCookieChangeReceivedPromise = new Promise(resolve => {
promise_test(async testCase => {
await kServiceWorkerActivatedPromise;
const subscriptions = [{ name: 'cookie-name', url: `${kScope}/path` }];
const subscriptions = [
{ name: 'cookie-name', matchType: 'equals', url: `${kScope}/path` },
];
await registration.cookies.subscribe(subscriptions);
testCase.add_cleanup(() => registration.cookies.unsubscribe(subscriptions));
......
......@@ -18,7 +18,9 @@ const kCookieChangeReceivedPromise = new Promise(resolve => {
promise_test(async testCase => {
await kServiceWorkerActivatedPromise;
const subscriptions = [{ name: 'cookie-name', url: `${kScope}/path` }];
const subscriptions = [
{ name: 'cookie-name', matchType: 'equals', url: `${kScope}/path` }
];
await registration.cookies.subscribe(subscriptions);
testCase.add_cleanup(() => registration.cookies.unsubscribe(subscriptions));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment