Fix ServerTiming results for resources that fail TAO check

Per spec (https://w3c.github.io/server-timing/#processing-model),
resources that fail the TAO check should return an empty array for
the serverTiming attribute.

Bug: 802321
Change-Id: I0bca0f38f0a975f7c85f4d8837a901bd8475d9b7
Reviewed-on: https://chromium-review.googlesource.com/870990
Commit-Queue: Yoav Weiss <yoav@yoav.ws>
Reviewed-by: Yoav Weiss <yoav@yoav.ws>
Cr-Commit-Position: refs/heads/master@{#530622}
diff --git a/server-timing/cross_origin.html b/server-timing/cross_origin.html
new file mode 100644
index 0000000..8003588
--- /dev/null
+++ b/server-timing/cross_origin.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<head>
+    <meta charset='utf-8' />
+    <script src="/resources/testharness.js"></script>
+    <script src='/resources/testharnessreport.js'></script>
+    <script src="/common/performance-timeline-utils.js"></script>
+    <script>
+      setup({explicit_done: true})
+
+      const {location: {href}} = document
+      const urls = {}
+      urls['same-origin'] = `${href.substring(0, href.lastIndexOf('/'))}/resources/blue.png`
+      urls['cross-origin'] = urls['same-origin'].replace('://', '://www.')
+      Object.keys(urls).forEach(function(key) {
+        const img = document.createElement('img')
+        img.src = urls[key]
+        document.getElementsByTagName('script')[0].parentNode.appendChild(img)
+      })
+
+      window.addEventListener('load', function() {
+        function assertServerTimingEntries(url, expectedEntryCount) {
+          test_equals(performance.getEntriesByName(url)[0].serverTiming.length,
+            expectedEntryCount,
+            `Expected entry count for ${url}: ${expectedEntryCount}`)
+        }
+        assertServerTimingEntries(urls['same-origin'], 1)
+        assertServerTimingEntries(urls['cross-origin'], 0)
+        done()
+      })
+    </script>
+</head>