Commit b7501173 authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[Background Fetch] Add layout tests for interfaces

exposed only to ServiceWorker context.

Bug: 894448
Change-Id: Iebc55a247b519d573d8cd8c9bdc384b496614fb9
Reviewed-on: https://chromium-review.googlesource.com/c/1276848Reviewed-by: default avatarJason Chase <chasej@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599222}
parent 0f4f8ddc
......@@ -18,14 +18,20 @@ test(t => {
'BackgroundFetchUpdateUIEvent': ['updateUI'],
'BackgroundFetchFetch': ['request'],
'BackgroundFetchRegistration': ['id', 'uploadTotal', 'uploaded',
'downloadTotal', 'downloaded', 'result',
'failureReason', 'recordsAvailable',
'onprogress'],
'downloadTotal', 'downloaded', 'result',
'failureReason', 'recordsAvailable',
'onprogress'],
'ServiceWorkerRegistration': ['backgroundFetch'],
});
}, 'BackgroundFetch API interfaces and properties in Origin-Trial enabled document.');
}, 'Background Fetch API interfaces and properties in Origin-Trial enabled document.');
fetch_tests_from_worker(new Worker('resources/backgroundfetch-origin-trial-interfaces-worker.js'));
// Only run "disabled" tests if the feature is not enabled via runtime flags.
if (!self.internals.runtimeFlags.backgroundFetchEnabled) {
service_worker_test('resources/backgroundfetch-origin-trial-interfaces-serviceworker-disabled.js');
}
service_worker_test('resources/backgroundfetch-origin-trial-interfaces-serviceworker-enabled.php');
</script>
importScripts('/resources/testharness.js',
'/resources/origin-trials-helper.js');
test(t => {
OriginTrialsHelper.check_interfaces_missing(
self,
['BackgroundFetchEvent', 'BackgroundFetchFetch', 'BackgroundFetchManager',
'BackgroundFetchUpdateUIEvent', 'BackgroundFetchRecord',
'BackgroundFetchRegistration', 'BackgroundFetchSettledFetch']);
}, 'Background Fetch API interfaces in Origin-Trial disabled worker.');
done();
<?php
// Generate token with the command:
// generate_token.py http://127.0.0.1:8000 BackgroundFetch --expire-timestamp=2000000000
header('Origin-Trial: AtDl/AukAuUX0Sw7KRz+mrV2vpSYrfDyVS4vdO3I1clqoNgKGqCX5Np5KIhlC6oQl8XcULXJz5bc9Y4CcYj9xA4AAABXeyJvcmlnaW4iOiAiaHR0cDovLzEyNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiQmFja2dyb3VuZEZldGNoIiwgImV4cGlyeSI6IDIwMDAwMDAwMDB9');
header('Content-Type: application/javascript');
?>
importScripts('/resources/testharness.js',
'/resources/origin-trials-helper.js');
test(t => {
OriginTrialsHelper.check_properties(this, {
'ServiceWorkerRegistration': ['backgroundFetch'],
'BackgroundFetchFetch': ['request'],
'BackgroundFetchManager': ['fetch', 'get', 'getIds'],
'BackgroundFetchEvent': ['registration'],
'BackgroundFetchUpdateUIEvent': ['updateUI'],
'BackgroundFetchRecord': ['request', 'responseReady'],
'BackgroundFetchSettledFetch': ['response'],
'BackgroundFetchRegistration': ['id', 'uploadTotal', 'uploaded',
'downloadTotal', 'downloaded', 'result',
'failureReason', 'recordsAvailable',
'onprogress', 'abort', 'match',
'matchAll'],
});
});
test(t => {
assert_true('onbackgroundfetchsuccess' in self, 'onbackgroundfetchsuccess property exists on global');
assert_true('onbackgroundfetchfail' in self, 'onbackgroundfetchfail property exists on global');
assert_true('onbackgroundfetchabort' in self, 'onbackgroundfetchabort property exists on global');
assert_true('onbackgroundfetchclick' in self, 'onbackgroundfetchclick property exists on global');
}, 'Background Fetch API entry points in Origin-Trial enabled serviceworker.');
done();
......@@ -12,6 +12,6 @@ test(t => {
'failureReason', 'recordsAvailable',
'onprogress'],
});
}, 'Background Fetch API interfaces and properties in Origin-Trial enabled worker.');
}, 'Background Fetch API interfaces in an Origin-Trial enabled worker.');
done();
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