Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / tools / page_cycler / indexed_db / common.js
1 // Copyright (c) 2012 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 var CANNOT_OPEN_DB = -1;
6 var SETUP_FAILED = -2;
7 var TEST_FAILED = -3;
8
9 function setup() {
10   window.indexedDB = window.indexedDB || window.webkitIndexedDB;
11   window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;
12
13   if ('indexedDB' in window)
14     return true;
15
16   return false;
17 }
18
19 function getOrAddElement(id, type) {
20   var elem = document.getElementById(id);
21   if (!elem) {
22     elem = document.createElement(type);
23     elem.id = id;
24     document.body.appendChild(elem);
25   }
26   return elem;
27 }
28
29 function log(msg) {
30   var logElem = getOrAddElement('logElem', 'DIV');
31   logElem.innerHTML += msg + '<br>';
32 }