Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: content/test/data/blob_storage/common.js

Issue 2516713002: [BlobStorage] Implementing disk. (Closed)
Patch Set: removed cleanup check, as mac doesn't run out event loops Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 function debug(message) 5 function debug(message) {
6 {
7 var span = document.createElement("span"); 6 var span = document.createElement("span");
8 span.appendChild(document.createTextNode(message)); 7 span.appendChild(document.createTextNode(message));
9 span.appendChild(document.createElement("br")); 8 span.appendChild(document.createElement("br"));
10 document.getElementById('status').appendChild(span); 9 document.getElementById('status').appendChild(span);
11 } 10 }
12 11
13 function done(message) 12 function done(message) {
14 {
15 if (document.location.hash == '#fail') 13 if (document.location.hash == '#fail')
16 return; 14 return;
17 if (message) 15 if (message)
18 debug('PASS: ' + message); 16 debug('PASS: ' + message);
19 else 17 else
20 debug('PASS'); 18 debug('PASS');
21 document.location.hash = '#pass'; 19 document.location.hash = '#pass';
22 } 20 }
23 21
24 function fail(message) 22 function fail(message) {
25 {
26 debug('FAILED: ' + message); 23 debug('FAILED: ' + message);
27 document.location.hash = '#fail'; 24 document.location.hash = '#fail';
28 } 25 }
29 26
30 function getLog() 27 function getLog() {
31 {
32 return "" + document.getElementById('status').innerHTML; 28 return "" + document.getElementById('status').innerHTML;
33 } 29 }
34 30
35 function unexpectedUpgradeNeededCallback(e)
36 {
37 fail('unexpectedUpgradeNeededCallback' +
38 ' (oldVersion: ' + e.oldVersion + ' newVersion: ' + e.newVersion + ')');
39 }
40
41 function unexpectedAbortCallback(e)
42 {
43 fail('unexpectedAbortCallback' +
44 ' (' + e.target.error.name + ': ' + e.target.error.message + ')');
45 }
46
47 function unexpectedSuccessCallback()
48 {
49 fail('unexpectedSuccessCallback');
50 }
51
52 function unexpectedCompleteCallback()
53 {
54 fail('unexpectedCompleteCallback');
55 }
56
57 function unexpectedErrorCallback(e)
58 {
59 fail('unexpectedErrorCallback' +
60 ' (' + e.target.error.name + ': ' + e.target.error.message + ')');
61 }
62
63 function unexpectedBlockedCallback(e)
64 {
65 fail('unexpectedBlockedCallback' +
66 ' (oldVersion: ' + e.oldVersion + ' newVersion: ' + e.newVersion + ')');
67 }
68
69 function deleteAllObjectStores(db)
70 {
71 objectStoreNames = db.objectStoreNames;
72 for (var i = 0; i < objectStoreNames.length; ++i)
73 db.deleteObjectStore(objectStoreNames[i]);
74 }
75
76 // The following functions are based on 31 // The following functions are based on
77 // WebKit/LayoutTests/fast/js/resources/js-test-pre.js 32 // WebKit/LayoutTests/fast/js/resources/js-test-pre.js
78 // so that the tests will look similar to the existing layout tests. 33 // so that the tests will look similar to the existing layout tests.
79 function stringify(v) 34 function stringify(v) {
80 {
81 if (v === 0 && 1/v < 0) 35 if (v === 0 && 1/v < 0)
82 return "-0"; 36 return "-0";
83 else return "" + v; 37 else return "" + v;
84 } 38 }
85 39
40 function areArraysEqual(a, b) {
41 try {
42 if (a.length !== b.length)
43 return false;
44 for (var i = 0; i < a.length; i++) {
45 if (a[i] !== b[i])
46 return false;
47 }
48 } catch (ex) {
49 return false;
50 }
51 return true;
52 }
53
86 function isResultCorrect(_actual, _expected) 54 function isResultCorrect(_actual, _expected)
87 { 55 {
88 if (_expected === 0) 56 if (_expected === 0)
89 return _actual === _expected && (1/_actual) === (1/_expected); 57 return _actual === _expected && (1/_actual) === (1/_expected);
90 if (_actual === _expected) 58 if (_actual === _expected)
91 return true; 59 return true;
92 if (typeof(_expected) == "number" && isNaN(_expected)) 60 if (typeof(_expected) == "number" && isNaN(_expected))
93 return typeof(_actual) == "number" && isNaN(_actual); 61 return typeof(_actual) == "number" && isNaN(_actual);
94 if (Object.prototype.toString.call(_expected) == 62 if (Object.prototype.toString.call(_expected) ==
95 Object.prototype.toString.call([])) 63 Object.prototype.toString.call([]))
(...skipping 22 matching lines...) Expand all
118 fail(_a + " should be " + _bv + ". Was " + stringify(_av) + "."); 86 fail(_a + " should be " + _bv + ". Was " + stringify(_av) + ".");
119 else 87 else
120 fail(_a + " should be " + _bv + " (of type " + typeof _bv + "). " + 88 fail(_a + " should be " + _bv + " (of type " + typeof _bv + "). " +
121 "Was " + _av + " (of type " + typeof _av + ")."); 89 "Was " + _av + " (of type " + typeof _av + ").");
122 } 90 }
123 91
124 function shouldBeTrue(_a) { shouldBe(_a, "true"); } 92 function shouldBeTrue(_a) { shouldBe(_a, "true"); }
125 function shouldBeFalse(_a) { shouldBe(_a, "false"); } 93 function shouldBeFalse(_a) { shouldBe(_a, "false"); }
126 function shouldBeNaN(_a) { shouldBe(_a, "NaN"); } 94 function shouldBeNaN(_a) { shouldBe(_a, "NaN"); }
127 function shouldBeNull(_a) { shouldBe(_a, "null"); } 95 function shouldBeNull(_a) { shouldBe(_a, "null"); }
128 function shouldBeEqualToString(a, b) 96 function shouldBeEqualToString(a, b) {
129 {
130 var unevaledString = '"' + b.replace(/\\/g, "\\\\").replace(/"/g, "\"") + '"'; 97 var unevaledString = '"' + b.replace(/\\/g, "\\\\").replace(/"/g, "\"") + '"';
131 shouldBe(a, unevaledString); 98 shouldBe(a, unevaledString);
132 } 99 }
133 100
134 function indexedDBTest(upgradeCallback, optionalOpenCallback) {
135 dbname = self.location.pathname.substring(
136 1 + self.location.pathname.lastIndexOf("/"));
137 var deleteRequest = indexedDB.deleteDatabase(dbname);
138 deleteRequest.onerror = unexpectedErrorCallback;
139 deleteRequest.onblocked = unexpectedBlockedCallback;
140 deleteRequest.onsuccess = function() {
141 var openRequest = indexedDB.open(dbname);
142 openRequest.onerror = unexpectedErrorCallback;
143 openRequest.onupgradeneeded = upgradeCallback;
144 openRequest.onblocked = unexpectedBlockedCallback;
145 if (optionalOpenCallback)
146 openRequest.onsuccess = optionalOpenCallback;
147 };
148 }
149
150 if (typeof String.prototype.startsWith !== 'function') { 101 if (typeof String.prototype.startsWith !== 'function') {
151 String.prototype.startsWith = function (str) { 102 String.prototype.startsWith = function (str) {
152 return this.indexOf(str) === 0; 103 return this.indexOf(str) === 0;
153 }; 104 };
154 } 105 }
OLDNEW
« no previous file with comments | « content/test/data/blob_storage/blob_creation_and_slicing.html ('k') | storage/browser/blob/blob_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698