Bug 1415740 P2 Add a WPT test to verify we report workerStart on cross-origin no-cors requests, like <img>. r=baku
authorBen Kelly <ben@wanderview.com>
Fri, 10 Nov 2017 00:33:59 -0800
changeset 391271 4762a6f8723887fc72c7adc28da8ee5731f0aa8d
parent 391270 9c74e8d1e1c3c31fe672058c4d6e09dd07f512ad
child 391272 647c6595838e0fd6f9dd5e4e8209c362b1159189
push id32868
push userryanvm@gmail.com
push dateFri, 10 Nov 2017 21:13:32 +0000
treeherdermozilla-central@092ccc6335a5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1415740
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1415740 P2 Add a WPT test to verify we report workerStart on cross-origin no-cors requests, like <img>. r=baku
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/service-workers/service-worker/resource-timing.https.html
testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.html
testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.sub.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -281866,17 +281866,17 @@
      {}
     ]
    ],
    "service-workers/service-worker/resources/request-headers.py": [
     [
      {}
     ]
    ],
-   "service-workers/service-worker/resources/resource-timing-iframe.html": [
+   "service-workers/service-worker/resources/resource-timing-iframe.sub.html": [
     [
      {}
     ]
    ],
    "service-workers/service-worker/resources/resource-timing-worker.js": [
     [
      {}
     ]
@@ -578696,17 +578696,17 @@
    "14dcf42e1dbfdc7589f9df64e2622cc599411174",
    "testharness"
   ],
   "service-workers/service-worker/request-end-to-end.https.html": [
    "ee9f8140b492daf89cb715643ee40557f6ed904e",
    "testharness"
   ],
   "service-workers/service-worker/resource-timing.https.html": [
-   "9ca1caf0b8216eda8956be0d98eb7b5ab2d92a43",
+   "a835a0baeb4fcc0c44e6be28502f89308464acc5",
    "testharness"
   ],
   "service-workers/service-worker/resources/404.py": [
    "567d0a7de3ef54adaa8339bb04632a2ecfcc57a5",
    "support"
   ],
   "service-workers/service-worker/resources/appcache-ordering.install.html": [
    "2fbe9f464383783774f08276b8e2cc7103fee83c",
@@ -579455,18 +579455,18 @@
   "service-workers/service-worker/resources/request-end-to-end-worker.js": [
    "984ea18286a9fa7446562a77284b942fa7e5217c",
    "support"
   ],
   "service-workers/service-worker/resources/request-headers.py": [
    "c939271e717288203a5a298b95a7328100bd7c80",
    "support"
   ],
-  "service-workers/service-worker/resources/resource-timing-iframe.html": [
-   "0fc85a13c536aad45a87fb073fdcebf371d4476d",
+  "service-workers/service-worker/resources/resource-timing-iframe.sub.html": [
+   "c18c96a25dec48ae9d53359d4ca987ba857878a1",
    "support"
   ],
   "service-workers/service-worker/resources/resource-timing-worker.js": [
    "45dd429936a3e3f558fac21a5a2e69ec7fa5ab5a",
    "support"
   ],
   "service-workers/service-worker/resources/respond-then-throw-worker.js": [
    "d57215bcad8a3966175930642dfd34281b11aeff",
--- a/testing/web-platform/tests/service-workers/service-worker/resource-timing.https.html
+++ b/testing/web-platform/tests/service-workers/service-worker/resource-timing.https.html
@@ -3,52 +3,74 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="/common/get-host-info.sub.js"></script>
 <script src="resources/test-helpers.sub.js"></script>
 <script>
 function resourceUrl(path) {
     return get_host_info()['HTTPS_ORIGIN'] + base_path() + path;
 }
 
-function verify(performance, resource, description) {
-    var entry = performance.getEntriesByName(resourceUrl(resource))[0];
+function crossOriginUrl(path) {
+    return get_host_info()['HTTPS_REMOTE_ORIGIN'] + base_path() + path;
+}
+
+function verify(performance, resource, mode, description) {
+    var url = mode === 'cross-origin' ? crossOriginUrl(resource)
+                                      : resourceUrl(resource);
+    var entryList = performance.getEntries();
+    var entry = performance.getEntriesByName(url)[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);
-    assert_greater_than_equal(entry.responseStart, entry.fetchStart, description);
-    assert_greater_than_equal(entry.responseEnd, entry.responseStart, description);
+    if (mode === 'cross-origin') {
+      assert_equals(entry.responseStart, 0, description);
+      assert_greater_than_equal(entry.responseEnd, entry.fetchStart, description);
+    } else {
+      assert_greater_than_equal(entry.responseStart, entry.fetchStart, description);
+      assert_greater_than_equal(entry.responseEnd, entry.responseStart, description);
+    }
     assert_greater_than(entry.responseEnd, entry.fetchStart, description);
     assert_greater_than(entry.duration, 0, description);
     if (resource.indexOf('redirect.py') != -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 scope = 'resources/resource-timing-iframe.sub.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/dummy.js', 'same-origin',
+                 'Generated response');
+          verify(performance, 'resources/empty.js', 'same-origin',
+                 'Network fallback');
           verify(performance, 'resources/redirect.py?Redirect=empty.js',
-                 'Redirect');
+                 'same-origin', 'Redirect');
+          verify(performance, 'resources/missing.jpg', 'same-origin',
+                 'Network fallback image');
+
+          // Test that worker start is available on cross-origin no-cors
+          // subresources.
+          verify(performance, 'resources/missing.jpg', 'cross-origin',
+                 'Network fallback cross-origin image');
+
           frame.remove();
           return registration.unregister();
         })
       .then(function() {
           t.done();
         })
       .catch(unreached_rejection(t));
 }, 'Controlled resource loads');
rename from testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.html
rename to testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.sub.html
--- a/testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.html
+++ b/testing/web-platform/tests/service-workers/service-worker/resources/resource-timing-iframe.sub.html
@@ -1,4 +1,6 @@
 <!DOCTYPE html>
 <script src="empty.js"></script>
 <script src="dummy.js"></script>
 <script src="redirect.py?Redirect=empty.js"></script>
+<img src="missing.jpg">
+<img src="https://{{domains[www1]}}:{{ports[https][0]}}/service-workers/service-worker/resources/missing.jpg">