1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // store some stuff in local storage
6 localStorage
.foo
= "bar";
8 console
.log("Opening database...");
9 // store some stuff in a database
10 var db
= window
.openDatabase("mydb2", "1.0", "database test", 2048);
12 chrome
.test
.notifyFail("failed to open database");
14 console
.log("Performing transaction...");
15 db
.transaction(function(tx
) {
16 tx
.executeSql("drop table if exists note", [], onDropSuccess
, onSqlError
);
17 tx
.executeSql("create table note (body text)", [], onCreateSuccess
, onSqlError
);
18 tx
.executeSql("insert into note values ('hotdog')", [], onSqlExecuted
,
21 chrome
.test
.notifyFail(error
.message
);
24 function onDropSuccess(tx
, res
) {
25 console
.log("note table dropped");
27 function onCreateSuccess(tx
, res
) {
28 console
.log("note table created");
30 function onSqlError(tx
, error
) {
31 chrome
.test
.notifyFail(error
.message
);
33 function onSqlExecuted() {
34 console
.log("Opening tab...");
35 // Open a tab. This doesn't really prove we're writing to disk, but it is
36 // difficult to prove that without shutting down the process. We'll just
37 // trust that if this next trick works, that the real testing for local
38 // storage is good enough to catch more subtle errors.