diff options
Diffstat (limited to 'dom/base/test/jsmodules/importmaps/test_externalImportMap.html')
-rw-r--r-- | dom/base/test/jsmodules/importmaps/test_externalImportMap.html | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/dom/base/test/jsmodules/importmaps/test_externalImportMap.html b/dom/base/test/jsmodules/importmaps/test_externalImportMap.html new file mode 100644 index 0000000000..1345f61947 --- /dev/null +++ b/dom/base/test/jsmodules/importmaps/test_externalImportMap.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Test an external import map</title> +<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + +<script> +let gotMsg = false; +let console = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService); +let listener = { + QueryInterface: ChromeUtils.generateQI(["nsIConsoleListener"]), + observe(msg) { + info("console message:" + msg); + ok(msg.logLevel == Ci.nsIConsoleMessage.warn, "log level should be 'warn'."); + // The message will be localized, so we just test the strings won't be + // localized. + ok(msg.message.match(/<script type='importmap'>.*src/), + "The error message should contain \"<script type='importmap'>\""); + console.unregisterListener(this); + gotMsg = true; + } +}; +console.registerListener(listener); +</script> + +<!--Import maps spec doesn't clearly define the format of an external import map script.--> +<script src="external_importMap.js" type="importmap" onload="scriptLoaded()" onerror="scriptError()"></script> + +<script> +function testLoaded() { + SimpleTest.waitForExplicitFinish(); + ok(gotMsg, "Should have got the console warning."); + SimpleTest.finish(); +} + +function scriptLoaded() { + ok(false, "Loading external import map script should have failed."); +} + +function scriptError() { + ok(true, "Loading external import map script failed."); +} +</script> +<body onload='testLoaded()'></body> |