Bug 1580804 [wpt PR 19015] - Adding resource timing test that checks for #hash in the URL, a=testonly
authorStoyan <ssttoo@ymail.com>
Thu, 03 Oct 2019 09:34:27 +0000
changeset 496588 ceb425cde83cfb67bd0f617e87583e2be5be8684
parent 496587 d7dd47456ce420381b08c192a6cf1fb726fbbc76
child 496589 193cbb3edaef4cc1ca73ae364ebe1c846b3c9c9a
push id36662
push userccoroiu@mozilla.com
push dateMon, 07 Oct 2019 21:53:50 +0000
treeherdermozilla-central@4651f71eeb54 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1580804, 19015
milestone71.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 1580804 [wpt PR 19015] - Adding resource timing test that checks for #hash in the URL, a=testonly Automatic update from web-platform-tests Adding resource timing test that checks for #hash in the URL (#19015) * Adding resource timing test that checks for #hash in the URL Mostly copypasta of the `resource-timing/resource_cached.htm` test Currently the test fails in Safari. Safari seems to strip the hash when it comes to images. XHRs look ok. * simpler hash test, no iframes using relatively recent features (filter and const), not sure if it's ok * removed EOL whitespace ./wpt lint resource-timing -- wpt-commits: 68abc3a55e4dcca5a5fc18c778619af0dee25d77 wpt-pr: 19015
testing/web-platform/tests/resource-timing/resource_hash.htm
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resource-timing/resource_hash.htm
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<title>Resource Timing: image with a hash</title>
+<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/webperftestharness.js"></script>
+<script src="resources/webperftestharnessextension.js"></script>
+<script>
+setup({explicit_done: true});
+
+// explicitly test the namespace before we start testing
+test_namespace("getEntriesByType");
+
+function onload_test() {
+  if (window.performance.getEntriesByType === undefined) {
+    done();
+    return;
+  }
+
+  const url = "resources/fake_responses.py?tag=" + Math.random() + '#hash=1';
+  const image = new Image();
+  image.onload = image.onerror = () => {
+    const entries = window.performance.getEntriesByType('resource').filter(r => r.initiatorType === 'img');
+    test_equals(entries.length, 1, "There should be one entry");
+    if (entries.length === 1) {
+        test_true(entries[0].name.indexOf('#hash=1') > -1, "There should be a hash in the resource name");
+    }
+    done();
+
+  }
+  image.src = url;
+}
+window.onload = onload_test;
+</script>
+</head>
+<body>
+<h1>Description</h1>
+<p>This test validates that a hash in an image URL is preserved in resource timing API results.</p>
+<div id="log"></div>
+</body>
+</html>