1 if (window.layoutTestController) {
2 layoutTestController.dumpAsText();
3 layoutTestController.waitUntilDone();
6 var video = document.getElementsByTagName('video')[0];
10 var console = document.createElement('div');
11 document.body.appendChild(console);
15 consoleWrite("FAIL: timed out");
16 if (window.layoutTestController)
17 layoutTestController.notifyDone();
19 setTimeout(hanged, 10000);
21 function testAndEnd(testFuncString)
23 test(testFuncString, true);
26 function test(testFuncString, endit)
28 if (eval(testFuncString))
29 consoleWrite("TEST(" + testFuncString + ") <span style='color:green'>OK</span>");
31 consoleWrite("TEST(" + testFuncString + ") <span style='color:red'>FAIL</span>");
37 function run(testFuncString)
39 consoleWrite("RUN(" + testFuncString + ")");
47 function waitForEventAndEnd(eventName, funcString)
49 waitForEvent(eventName, funcString, true)
52 function waitForEvent(eventName, func, endit)
54 function _eventCallback(event)
56 consoleWrite("EVENT(" + eventName + ")");
65 media.addEventListener(eventName, _eventCallback);
68 function waitForEventTestAndEnd(eventName, testFuncString)
70 waitForEventAndTest(eventName, testFuncString, true);
73 function waitForEventAndFail(eventName)
75 waitForEventAndTest(eventName, "false", true);
78 function waitForEventAndTest(eventName, testFuncString, endit)
80 function _eventCallback(event)
82 if (eval(testFuncString))
83 consoleWrite("EVENT(" + eventName + ") TEST(" + testFuncString + ") <span style='color:green'>OK</span>");
85 consoleWrite("EVENT(" + eventName + ") TEST(" + testFuncString + ") <span style='color:red'>FAIL</span>");
91 media.addEventListener(eventName, _eventCallback);
94 function testException(testString, exceptionString)
99 if (ex.code == eval(exceptionString))
100 consoleWrite("TEST(" + testString + ") THROWS("+exceptionString+") <span style='color:green'>OK</span>");
102 consoleWrite("TEST(" + testString + ") THROWS("+exceptionString+") <span style='color:red'>FAIL</span>");
106 var testEnded = false;
110 consoleWrite("END OF TEST");
112 if (window.layoutTestController)
113 layoutTestController.notifyDone();
116 function endTestLater()
118 setTimeout(endTest, 250);
121 function failTestIn(ms)
123 setTimeout(function () {
124 consoleWrite("FAIL: did not end fast enough");
129 function consoleWrite(text)
133 console.innerHTML += text + "<br>";
136 function relativeURL(url)
138 return url.substr(url.indexOf('/media/')+7);