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