|
| 1 | +<!DOCTYPE html> |
| 2 | +<meta charset=utf-8> |
| 3 | +<head> |
| 4 | +<title>Test speculative preload of external script doesn't conflict with import map</title> |
| 5 | +<script src="/tests/SimpleTest/SimpleTest.js"></script> |
| 6 | +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
| 7 | +</head> |
| 8 | + |
| 9 | +<!-- |
| 10 | + These tests check that speculative preloading, which could happen before |
| 11 | + the import map is installed, doesn't load the wrong modules. This version |
| 12 | + dynamically inserts the import map script element after speculative |
| 13 | + preloading has started. |
| 14 | +--> |
| 15 | + |
| 16 | +<script> |
| 17 | + const script = document.createElement('script'); |
| 18 | + script.type = 'importmap'; |
| 19 | + script.textContent = |
| 20 | + `{ |
| 21 | + "imports": { |
| 22 | + "bare": "./good/module_0.mjs", |
| 23 | + "./bad/module_1.mjs": "./good/module_1.mjs", |
| 24 | + "./bad/module_2.mjs": "./good/module_2.mjs", |
| 25 | + "./bad/module_3.mjs": "./good/module_3.mjs", |
| 26 | + "./bad/module_4.mjs": "./good/module_4.mjs", |
| 27 | + "./bad/module_7.mjs": "./good/module_7.mjs" |
| 28 | + } |
| 29 | + }`; |
| 30 | + document.head.appendChild(script); |
| 31 | +</script> |
| 32 | + |
| 33 | +<!-- |
| 34 | +Test bareword import (not supported before import map installed). |
| 35 | +--> |
| 36 | +<script type="module" src="module_importMap_with_external_script_0.mjs"></script> |
| 37 | + |
| 38 | +<!-- |
| 39 | +Test mapping from missing resource to existing resource (not found before |
| 40 | +import map installed). |
| 41 | +--> |
| 42 | +<script type="module" src="module_importMap_with_external_script_1.mjs"></script> |
| 43 | + |
| 44 | +<!-- |
| 45 | +Test mapping from one existing resource to another (would load wrong resource before |
| 46 | +import map installed). |
| 47 | +--> |
| 48 | +<script type="module" src="module_importMap_with_external_script_2.mjs"></script> |
| 49 | + |
| 50 | +<!-- |
| 51 | +Test mapping from one existing resource to another with circular dependency. |
| 52 | +--> |
| 53 | +<script type="module" src="module_importMap_with_external_script_3.mjs"></script> |
| 54 | + |
| 55 | +<!-- |
| 56 | +Test with redirect, script_6.mjs -> script_5.mjs -> script_4.mjs. |
| 57 | +We redirect twice here, as sometimes one redirect can't reproduce the crash |
| 58 | +from bug 1835468. |
| 59 | +--> |
| 60 | +<script type="module" src="module_importMap_with_external_script_6.mjs"></script> |
| 61 | + |
| 62 | +<!-- |
| 63 | +Test with async attribute |
| 64 | +--> |
| 65 | +<script type="module" async src="module_importMap_with_external_script_7.mjs"></script> |
| 66 | + |
| 67 | +<script> |
| 68 | + SimpleTest.waitForExplicitFinish(); |
| 69 | + |
| 70 | + let passCount = 0; |
| 71 | + const expectedCount = 6; |
| 72 | + |
| 73 | + function success(name) { |
| 74 | + ok(true, "Test passed, loaded " + name); |
| 75 | + passCount++; |
| 76 | + if (passCount == expectedCount) { |
| 77 | + SimpleTest.finish(); |
| 78 | + } |
| 79 | + } |
| 80 | +</script> |
| 81 | +<body></body> |
0 commit comments