| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <script> | |
| 4 | |
| 5 function writeMessageToLog(message) | |
| 6 { | |
| 7 document.getElementById("console").innerText += message + "\n"; | |
| 8 } | |
| 9 | |
| 10 var setupStatements = [ | |
| 11 "CREATE TABLE IF NOT EXISTS PrivateTest1 (randomData)", | |
| 12 "INSERT INTO PrivateTest1 VALUES ('somedata')" | |
| 13 ]; | |
| 14 | |
| 15 var privateBrowsingStatements = [ | |
| 16 "CREATE TABLE IF NOT EXISTS PrivateTest2 (randomData)", | |
| 17 "DELETE FROM PrivateTest1", | |
| 18 "DROP TABLE PrivateTest1", | |
| 19 "INSERT INTO PrivateTest1 VALUES ('somedata')", | |
| 20 "SELECT * FROM PrivateTest1" | |
| 21 ]; | |
| 22 | |
| 23 var completed = 0; | |
| 24 var theTransaction; | |
| 25 | |
| 26 function setupSuccessFunction(tx, result) | |
| 27 { | |
| 28 ++completed; | |
| 29 writeMessageToLog("Setup statement " + completed + " completed successfully"
); | |
| 30 checkSetupComplete(); | |
| 31 } | |
| 32 | |
| 33 function setupErrorFunction(tx, error) | |
| 34 { | |
| 35 ++completed; | |
| 36 writeMessageToLog("Setup statement " + completed + " completed with an error
\n" + error.message); | |
| 37 checkSetupComplete(); | |
| 38 } | |
| 39 | |
| 40 function privateBrowsingSuccessFunction(tx, result) | |
| 41 { | |
| 42 ++completed; | |
| 43 writeMessageToLog("Private browsing statement " + completed + " completed su
ccessfully"); | |
| 44 } | |
| 45 | |
| 46 function privateBrowsingErrorFunction(tx, error) | |
| 47 { | |
| 48 ++completed; | |
| 49 writeMessageToLog("Private browsing statement " + completed + " completed wi
th an error\n" + error.message); | |
| 50 return false; | |
| 51 } | |
| 52 | |
| 53 function runSetup(transaction) | |
| 54 { | |
| 55 theTransaction = transaction; | |
| 56 for (i in setupStatements) | |
| 57 theTransaction.executeSql(setupStatements[i], [], setupSuccessFunction,
setupErrorFunction); | |
| 58 } | |
| 59 | |
| 60 function checkSetupComplete() | |
| 61 { | |
| 62 if (completed == setupStatements.length) | |
| 63 runPrivateBrowsingTests(); | |
| 64 } | |
| 65 | |
| 66 function runPrivateBrowsingTests() | |
| 67 { | |
| 68 completed = 0; | |
| 69 | |
| 70 if (window.testRunner) | |
| 71 testRunner.setPrivateBrowsingEnabled(true); | |
| 72 | |
| 73 for (i in privateBrowsingStatements) | |
| 74 theTransaction.executeSql(privateBrowsingStatements[i], [], privateBrows
ingSuccessFunction, privateBrowsingErrorFunction); | |
| 75 } | |
| 76 | |
| 77 function endTest() | |
| 78 { | |
| 79 writeMessageToLog("Test ended"); | |
| 80 | |
| 81 if (window.testRunner) | |
| 82 testRunner.notifyDone(); | |
| 83 } | |
| 84 | |
| 85 function runTest() | |
| 86 { | |
| 87 if (window.testRunner) { | |
| 88 testRunner.dumpAsText(); | |
| 89 testRunner.waitUntilDone(); | |
| 90 } | |
| 91 | |
| 92 var database = openDatabase("PrivateBrowsingNoReadNoWriteTest", "1.0", "Test
private browsing no read/write safety", 1); | |
| 93 database.transaction(runSetup, endTest, endTest); | |
| 94 } | |
| 95 | |
| 96 </script> | |
| 97 </head> | |
| 98 <body onload="runTest();"> | |
| 99 This test makes sure that attempts to change the database during private browsin
g fail.<br> | |
| 100 <div id="console"></div> | |
| 101 </body> | |
| 102 </html> | |
| OLD | NEW |