OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 // store some stuff in local storage |
| 6 localStorage.foo = "bar"; |
| 7 |
| 8 console.log("Opening database..."); |
| 9 // store some stuff in a database |
| 10 var db = window.openDatabase("mydb2", "1.0", "database test", 2048); |
| 11 if (!db) |
| 12 chrome.test.notifyFail("failed to open database"); |
| 13 |
| 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, |
| 19 onSqlError); |
| 20 }, function(error) { |
| 21 chrome.test.notifyFail(error.message); |
| 22 }); |
| 23 |
| 24 function onDropSuccess(tx, res) { |
| 25 console.log("note table dropped"); |
| 26 } |
| 27 function onCreateSuccess(tx, res) { |
| 28 console.log("note table created"); |
| 29 } |
| 30 function onSqlError(tx, error) { |
| 31 chrome.test.notifyFail(error.message); |
| 32 } |
| 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. |
| 39 chrome.tabs.create({ |
| 40 url: "tab.html" |
| 41 }); |
| 42 } |
OLD | NEW |