Commit 627de60e authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[Background Sync] Origin trials integration

for Periodic Background Sync.
Also added a web_test to verify the expected interfaces.

Bug: 925297
Change-Id: I9d8791d676becaf4816918cac75bd4fec13363ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1713504
Auto-Submit: Mugdha Lakhani <nator@chromium.org>
Commit-Queue: Mike West <mkwst@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#679962}
parent fcf04763
...@@ -145,7 +145,8 @@ PermissionDescriptorPtr ParsePermission(ScriptState* script_state, ...@@ -145,7 +145,8 @@ PermissionDescriptorPtr ParsePermission(ScriptState* script_state,
if (name == "idle-detection") if (name == "idle-detection")
return CreatePermissionDescriptor(PermissionName::IDLE_DETECTION); return CreatePermissionDescriptor(PermissionName::IDLE_DETECTION);
if (name == "periodic-background-sync") { if (name == "periodic-background-sync") {
if (!RuntimeEnabledFeatures::PeriodicBackgroundSyncEnabled()) { if (!RuntimeEnabledFeatures::PeriodicBackgroundSyncEnabled(
ExecutionContext::From(script_state))) {
exception_state.ThrowTypeError( exception_state.ThrowTypeError(
"Periodic Background Sync is not enabled."); "Periodic Background Sync is not enabled.");
return nullptr; return nullptr;
......
...@@ -1187,6 +1187,7 @@ ...@@ -1187,6 +1187,7 @@
}, },
{ {
name: "PeriodicBackgroundSync", name: "PeriodicBackgroundSync",
origin_trial_feature_name: "PeriodicBackgroundSync",
settable_from_internals: true, settable_from_internals: true,
status: "test", status: "test",
}, },
......
importScripts('/resources/testharness.js',
'/resources/origin-trials-helper.js');
test(t => {
OriginTrialsHelper.check_properties_exist(this, {
'ServiceWorkerRegistration': ['periodicSync'],
'PeriodicSyncManager': ['register', 'getTags', 'unregister'],
'PeriodicSyncEvent': ['tag'],
});
}, 'Periodic Background Sync API interfaces and properties in Origin-Trial enabled worker.');
done();
\ No newline at end of file
<!DOCTYPE html>
<meta charset="utf-8">
<!-- Generate token with the command:
generate_token.py http://127.0.0.1:8000 PeriodicBackgroundSync --expire-timestamp=2000000000
-->
<meta http-equiv="origin-trial" content="ArBC4XZnvKrTOwjYpe4wXy6t+PrIdFoyqLkTNBVamdBgdFTxwMc9xfEJonBUlsX1LLLTzzLKhFZujvwwZrbPog8AAABeeyJvcmlnaW4iOiAiaHR0cDovLzEyNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiUGVyaW9kaWNCYWNrZ3JvdW5kU3luYyIsICJleHBpcnkiOiAyMDAwMDAwMDAwfQ==" />
<title>Periodic Background Sync API - interfaces exposed by origin trial</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/origin-trials-helper.js"></script>
<script src="/serviceworker/resources/test-helpers.js"></script>
<script>
test(t => {
OriginTrialsHelper.check_properties_exist(this, {
'PeriodicSyncManager': ['register', 'getTags', 'unregister'],
'ServiceWorkerRegistration': ['periodicSync'],
});
}, 'Periodic Background Sync API interfaces and properties in Origin-Trial enabled document.');
service_worker_test('resources/periodic-background-sync-origin-trial-interfaces-worker.php');
</script>
\ No newline at end of file
<?php
// Generate token with the command:
// generate_token.py http://127.0.0.1:8000 PeriodicBackgroundSync --expire-timestamp=2000000000
header("Origin-Trial: ArBC4XZnvKrTOwjYpe4wXy6t+PrIdFoyqLkTNBVamdBgdFTxwMc9xfEJonBUlsX1LLLTzzLKhFZujvwwZrbPog8AAABeeyJvcmlnaW4iOiAiaHR0cDovLzEyNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiUGVyaW9kaWNCYWNrZ3JvdW5kU3luYyIsICJleHBpcnkiOiAyMDAwMDAwMDAwfQ==");
header('Content-Type: application/javascript');
?>
importScripts('/resources/testharness.js',
'/resources/origin-trials-helper.js');
test(t => {
OriginTrialsHelper.check_properties_exist(this, {
'ServiceWorkerRegistration': ['periodicSync'],
'PeriodicSyncManager': ['register', 'getTags', 'unregister'],
'PeriodicSyncEvent': ['tag'],
});
}, 'Periodic Background Sync API interfaces and properties in Origin-Trial enabled worker.');
done();
\ No newline at end of file
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