2010-05-28 Eric Uhrhane <ericu@chromium.org>
[WebKit-https.git] / LayoutTests / fast / workers / storage / resources / database-worker-controller.js
1 var databaseWorker = new Worker('resources/database-worker.js');
2
3 databaseWorker.onerror = function(event) {
4     log("Caught an error from the worker!");
5     log(event);
6     for (var i in event)
7         log("event[" + i + "]: " + event[i]);
8 };
9
10 databaseWorker.onmessage = function(event) {
11     if (event.data.indexOf('log:') == 0) {
12         log(event.data.substring(4));
13     } else if (event.data == 'notifyDone') {
14         if (window.layoutTestController)
15             layoutTestController.notifyDone();
16     } else if (event.data.indexOf('setLocationHash:') == '0') {
17         location.hash = event.data.substring('setLocationHash:'.length);
18     } else if (event.data == 'back') {
19         history.back();
20     } else
21         throw new Error("Unrecognized message: " + event);
22 };
23
24 function log(message)
25 {
26     document.getElementById("console").innerText += message + "\n";
27 }
28
29 function runTest(testFile)
30 {
31     if (window.layoutTestController) {
32         layoutTestController.dumpAsText();
33         layoutTestController.waitUntilDone();
34     }
35     document.getElementById("console").innerText = "";
36     databaseWorker.postMessage("importScripts:../../../storage/" + testFile);
37     databaseWorker.postMessage("runTest");
38 }
39