| <!doctype html> | |
| <meta charset=utf-8> | |
| <script src="/resources/testharness.js"></script> | |
| <script src="/resources/testharnessreport.js"></script> | |
| <body> | |
| <script> | |
| function attachAndWaitForLoad(element) { | |
| return new Promise((resolve, reject) => { | |
| element.onload = resolve; | |
| element.onerror = reject; | |
| document.body.appendChild(element); | |
| }); | |
| } | |
| promise_test(function(t) { | |
| const link = document.createElement('link'); | |
| link.rel = 'modulepreload'; | |
| link.as = 'json'; | |
| link.href = 'resources/dummy.json'; | |
| return attachAndWaitForLoad(link).then(() => { | |
| const absoluteURL = new URL(link.href, location.href).href; | |
| assert_equals(performance.getEntriesByName(absoluteURL).length, 1, absoluteURL); | |
| }); | |
| }, 'link rel=modulepreload with as=json should preload JSON module'); | |
| </script> |