2 var printFullTestDetails = true; // This is optionaly switched of by test whose tested values can differ. (see disableFullTestDetailsPrinting())
7 if (window.layoutTestController) {
8 layoutTestController.dumpAsText(runPixelTests);
9 layoutTestController.waitUntilDone();
12 function runWithKeyDown(fn)
14 // FIXME: WKTR does not yet support the keyDown() message. Do a mouseDown here
15 // instead until keyDown support is added.
16 var eventName = !window.layoutTestController || eventSender.keyDown ? 'keypress' : 'mousedown'
19 document.removeEventListener(eventName, thunk, false);
22 document.addEventListener(eventName, thunk, false);
24 if (window.layoutTestController) {
25 if (eventSender.keyDown)
26 eventSender.keyDown(" ", []);
28 eventSender.mouseDown();
34 if (!console && document.body) {
35 console = document.createElement('div');
36 document.body.appendChild(console);
41 function testAndEnd(testFuncString)
43 test(testFuncString, true);
46 function test(testFuncString, endit)
48 logResult(eval(testFuncString), "TEST(" + testFuncString + ")");
53 function testExpected(testFuncString, expected, comparison)
56 var observed = eval(testFuncString);
62 if (comparison === undefined)
68 case '<': success = observed < expected; break;
69 case '<=': success = observed <= expected; break;
70 case '>': success = observed > expected; break;
71 case '>=': success = observed >= expected; break;
72 case '!=': success = observed != expected; break;
73 case '==': success = observed == expected; break;
76 reportExpected(success, testFuncString, comparison, expected, observed)
81 function reportExpected(success, testFuncString, comparison, expected, observed)
85 var msg = "Test " + testNumber;
87 if (printFullTestDetails || !success)
88 msg = "EXPECTED (<em>" + testFuncString + " </em>" + comparison + " '<em>" + expected + "</em>')";
91 msg += ", OBSERVED '<em>" + observed + "</em>'";
93 logResult(success, msg);
96 function waitForEventAndEnd(element, eventName, funcString)
98 waitForEvent(element, eventName, funcString, true)
101 function waitForEvent(element, eventName, func, endit)
103 function _eventCallback(event)
105 consoleWrite("EVENT(" + eventName + ")");
114 element.addEventListener(eventName, _eventCallback);
117 function waitForEventAndTest(element, eventName, testFuncString, endit)
119 function _eventCallback(event)
121 logResult(eval(testFuncString), "EVENT(" + eventName + ") TEST(" + testFuncString + ")");
126 element.addEventListener(eventName, _eventCallback);
129 function waitForEventTestAndEnd(element, eventName, testFuncString)
131 waitForEventAndTest(element, eventName, testFuncString, true);
134 var testEnded = false;
138 consoleWrite("END OF TEST");
140 if (window.layoutTestController)
141 layoutTestController.notifyDone();
144 function logResult(success, text)
147 consoleWrite(text + " <span style='color:green'>OK</span>");
149 consoleWrite(text + " <span style='color:red'>FAIL</span>");
152 function consoleWrite(text)
156 logConsole().innerHTML += text + "<br>";