blob: b28e907bc0458d0c796a96f5f523aab87beb51f8 [file] [log] [blame]
<?xml version="1.0"?>
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml" onerror="testGlobalErrorHandlerNotFired(evt)">
<defs>
<title>&lt;SCRIPT&gt; load and error events</title>
<script type="text/javascript">
//<![CDATA[
var status_ = new Array();
var shouldContinue = 1;
var lastTest = 0;
for (i = 0; i < 7; ++i)
status_[i] = "";
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function testGlobalErrorHandlerNotFired(evt) {
status_[evt.target.id] += "G";
}
function loadEventHandler(evt) {
status_[evt.target.id] += "L";
}
function errorEventHandler(evt) {
status_[evt.target.id] += "E";
if (lastTest)
window.setTimeout('endTest()', 0);
}
function endTest() {
var failures = "";
if (status_[0] != "E")
failures += "0 (actual result: " + status_[0] + ") ";
if (status_[1] != "E")
failures += "1 (actual result: " + status_[1] + ") ";
if (status_[2] != "L")
failures += "2 (actual result: " + status_[2] + ") ";
if (status_[3] != "L")
failures += "3 (actual result: " + status_[3] + ") ";
if (status_[4] != "L")
failures += "4 (actual result: " + status_[4] + ") ";
if (status_[5] != "E")
failures += "5 (actual result: " + status_[5] + ") ";
if (status_[6] != "E")
failures += "6 (actual result: " + status_[6] + ")";
var results = document.getElementById("results");
if (failures)
results.innerHTML = "FAIL: The following tests failed: " + failures;
else
results.innerHTML = "PASS";
if (window.testRunner)
testRunner.notifyDone();
}
function lastTestBeforeRootElementLoaded() {
window.setTimeout('startDynamicTests()', 0);
}
function startDynamicTests() {
if (shouldContinue) {
var scriptElement = document.createElementNS("http://www.w3.org/2000/svg", "svg:script");
scriptElement.id = 4;
scriptElement.type.baseVal = "text/javascript";
scriptElement.href.baseVal = "resources/script-load.js";
scriptElement.onload = function(loadEvent) {
loadEventHandler(loadEvent);
window.setTimeout('continueDynamicTest1()', 0);
};
document.getElementsByTagName("defs")[0].appendChild(scriptElement);
} else {
var results = document.getElementById("results");
results.innerHTML = "FAIL: SVGLoad event on root element shouldn't fire.";
if (window.testRunner)
testRunner.notifyDone();
}
}
function continueDynamicTest1() {
var scriptElement = document.createElementNS("http://www.w3.org/2000/svg", "svg:script");
scriptElement.id = 5;
scriptElement.type.baseVal = "text/javascript";
scriptElement.href.baseVal = "resources/nonexistent.js";
scriptElement.onload = loadEventHandler;
scriptElement.onerror = function(errorEvent) {
errorEventHandler(errorEvent);
window.setTimeout('continueDynamicTest2()', 0);
};
document.getElementsByTagName("defs")[0].appendChild(scriptElement);
}
function continueDynamicTest2() {
var scriptElement = document.createElementNS("http://www.w3.org/2000/svg", "svg:script");
scriptElement.id = 6;
scriptElement.type.baseVal = "text/javascript";
scriptElement.href.baseVal = "resources/nonexistent.js";
scriptElement.onerror = errorEventHandler;
lastTest = 1;
document.getElementsByTagName("defs")[0].appendChild(scriptElement);
}
//]]>
</script>
<script id="0" type="text/javascript" onerror="errorEventHandler(evt)" onload="loadEventHandler(evt)" xlink:href="resources/certainlydoesnotexist.js"></script>
<script id="1" type="text/javascript" onerror="errorEventHandler(evt)" onload="loadEventHandler(evt)" xlink:href="resources/certainlydoesnotexisttoo.js"/>
<script id="2" type="text/javascript" onerror="errorEventHandler(evt)" onload="loadEventHandler(evt)" xlink:href="resources/script-load.js"></script>
<script id="3" type="text/javascript" onerror="errorEventHandler(evt)" onload="loadEventHandler(evt); lastTestBeforeRootElementLoaded();" xlink:href="resources/script-load.js"/>
</defs>
<foreignObject>
Test load and error event handling with SVGScriptElement
<xhtml:hr/>
<xhtml:p id="results">FAIL: Test never finished.</xhtml:p>
</foreignObject>
</svg>