Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / intversion-encoding.js
blob60d8c899504ff4412ee047f38519a055bc02687b
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("Test that integer versions are encoded/decoded consistently.");
8 versions = [1,
9             0x7f,
10             0x80,
11             0x80000000,
12             9007199254740991]; // 2^53-1, maximum JavaScript integer.
14 function test()
16     setDBNameFromPath();
17     request = evalAndLog("indexedDB.deleteDatabase(dbname)");
18     request.onblocked = unexpectedBlockedCallback;
19     request.onerror = unexpectedErrorCallback;
20     request.onsuccess = openFirstTime;
23 function openFirstTime(evt) {
24     preamble(evt);
26     if (!versions.length) {
27         finishJSTest();
28         return;
29     }
31     evalAndLog("version = " + versions.shift());
32     evalAndLog("upgradeNeededFired = false");
33     evalAndLog("request = indexedDB.open(dbname, version)");
34     request.onblocked = unexpectedBlockedCallback;
35     request.onerror = unexpectedErrorCallback;
36     request.onupgradeneeded = function() {
37         evalAndLog("upgradeNeededFired = true");
38         evalAndLog("db = request.result");
39         shouldBe("db.version", "version");
40     };
41     request.onsuccess = function() {
42         shouldBeTrue("upgradeNeededFired");
43         evalAndLog("db = request.result");
44         shouldBe("db.version", "version");
45         evalAndLog("db.close()");
46         openSecondTime();
47     };
50 function openSecondTime() {
51     preamble();
52     evalAndLog("request = indexedDB.open(dbname)");
53     request.onblocked = unexpectedBlockedCallback;
54     request.onerror = unexpectedErrorCallback;
55     request.onupgradeneeded = unexpectedUpgradeNeededCallback;
56     request.onsuccess = function() {
57         evalAndLog("db = request.result");
58         shouldBe("db.version", "version");
59         evalAndLog("db.close()");
60         openFirstTime();
61     };
64 test();