Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/budget/get-budget-in-service-worker.html

Issue 2273743002: Framework and tests for WorkerNavigatorBudget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo_service
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/budget/get-budget-in-service-worker.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/budget/get-budget-in-service-worker.html b/third_party/WebKit/LayoutTests/http/tests/budget/get-budget-in-service-worker.html
new file mode 100644
index 0000000000000000000000000000000000000000..4946046258105b9e3e0c93c4b2199ca82f66f93f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/budget/get-budget-in-service-worker.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>getBudget succeeds from a Service Worker</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../serviceworker/resources/test-helpers.js"></script>
+<script src="../notifications/resources/test-helpers.js"></script>
harkness 2016/08/23 16:10:51 I could also copy the helpers from notifications t
+<script src="/js-test-resources/mojo-helpers.js"></script>
+<script src="budget-service-mock.js"></script>
+</head>
+<body>
+<script>
+async_test(function(test) {
+ var script = 'resources/instrumentation-service-worker.js';
+ var scope = 'resources/scope/' + location.pathname;
+ var port;
+
+ budgetServiceMock.then(mock => {
+ getActiveServiceWorkerWithMessagePort(test, script, scope)
+ .then(function(workerInfo) {
+ port = workerInfo.port;
+ port.postMessage({command: 'getBudget'});
+
+ port.addEventListener('message', function(event) {
+ if (typeof event.data != 'object' || !event.data.command)
+ assert_unreached('Invalid message from the service worker');
+
+ assert_equals(event.data.command, 'getBudget');
+ assert_true(event.data.success,
+ 'getBudget should succeed. Error message: ' + event.data.errorMessage);
+ assert_equals(event.data.budgetAt, TEST_BUDGET_AT);
+ assert_equals(event.data.time, TEST_BUDGET_TIME);
+ test.done();
+ });
+ })
+ .catch(unreached_rejection(test));
+ });
+}, 'getBudget should succeed from Service Worker');
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698