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

Unified Diff: LayoutTests/http/tests/serviceworker/resource-timing.html

Issue 1152673004: Add workerStart attribute to ResourceTiming (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/resources/resource-timing-iframe.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/resource-timing.html
diff --git a/LayoutTests/http/tests/serviceworker/resource-timing.html b/LayoutTests/http/tests/serviceworker/resource-timing.html
new file mode 100644
index 0000000000000000000000000000000000000000..29600aa1b1732a0a7af1c74f978b6d73c9534173
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/resource-timing.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../resources/get-host-info.js"></script>
+<script src="resources/test-helpers.js"></script>
+<script>
+function resourceUrl(path) {
+ return get_host_info()['HTTP_ORIGIN'] + base_path() + path;
+}
+
+function verify(performance, resource, description) {
+ var entry = performance.getEntriesByName(resourceUrl(resource))[0];
+ assert_greater_than(entry.workerStart, 0, description);
+ assert_greater_than_equal(entry.workerStart, entry.startTime, description);
+ assert_less_than_equal(entry.workerStart, entry.fetchStart, description);
+ if (resource.indexOf('redirect.php') != -1) {
+ assert_less_than_equal(entry.workerStart, entry.redirectStart,
+ description);
+ } else {
+ assert_equals(entry.redirectStart, 0, description);
+ }
+}
+
+async_test(function(t) {
+ var worker_url = 'resources/resource-timing-worker.js';
+ var scope = 'resources/resource-timing-iframe.html';
+ var registration;
+
+ service_worker_unregister_and_register(t, worker_url, scope)
+ .then(function(r) {
+ registration = r;
+ return wait_for_state(t, r.installing, 'activated');
+ })
+ .then(function() {
+ return with_iframe(scope);
+ })
+ .then(function(frame) {
+ var performance = frame.contentWindow.performance;
+ verify(performance, 'resources/dummy.js', 'Generated response');
+ verify(performance, 'resources/empty.js', 'Network fallback');
+ verify(performance, 'resources/redirect.php?Redirect=empty.js',
+ 'Redirect');
+ frame.remove();
+ return registration.unregister();
+ })
+ .then(function() {
+ t.done();
+ })
+ .catch(unreached_rejection(t));
+}, 'Controlled resource loads');
+
+test(function() {
+ var url = resourceUrl('resources/test-helpers.js');
+ var entry = window.performance.getEntriesByName(url)[0];
+ assert_equals(entry.workerStart, 0, 'Non-controlled');
+}, 'Non-controlled resource loads');
+
+</script>
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/resources/resource-timing-iframe.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698