| <script src="../../resources/js-test-pre.js"></script> |
| <script> |
| jsTestIsAsync = true; |
| |
| description("First load a script with a wrong charset then again with the right one. Second attempt should work and 'scriptSuccess' should be set to true."); |
| |
| function appendScriptWithCharset(charset, onload) |
| { |
| var script = document.createElement("script"); |
| script.src = "resources/success.js"; |
| script.setAttribute("charset", charset); |
| script.onload = onload; |
| script.onerror = onload; |
| document.body.appendChild(script); |
| } |
| |
| function test() |
| { |
| debug("Loading with the wrong encoding..."); |
| appendScriptWithCharset("utf-16", function () { |
| // We should get a SyntaxError since the script was loaded with the wrong encoding. |
| shouldHaveHadError("SyntaxError"); |
| shouldBeUndefined("window.scriptSuccess"); |
| |
| debug("Now loading with the right encoding..."); |
| appendScriptWithCharset("utf-8", function () { |
| shouldBeTrue("scriptSuccess"); |
| finishJSTest(); |
| }); |
| }); |
| } |
| </script> |
| <body onload="test()"> |
| <script src="../../resources/js-test-post.js"></script> |