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

Unified Diff: third_party/WebKit/LayoutTests/storage/quota/storagemanager-estimate.html

Issue 2791963004: Upstream StorageManager estimate() test to WPT (Closed)
Patch Set: Update comment per review feedback Created 3 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/storage/storagemanager-estimate.https.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/storage/quota/storagemanager-estimate.html
diff --git a/third_party/WebKit/LayoutTests/storage/quota/storagemanager-estimate.html b/third_party/WebKit/LayoutTests/storage/quota/storagemanager-estimate.html
deleted file mode 100644
index 470f3bdfbea4ace0de042b9d8e90f6cac3ba1085..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/storage/quota/storagemanager-estimate.html
+++ /dev/null
@@ -1,81 +0,0 @@
-<!DOCTYPE html>
-<title>StorageManager: estimate()</title>
-<script src="../../resources/testharness.js"></script>
-<script src="../../resources/testharnessreport.js"></script>
-<script>
-
-test(function(t) {
- assert_true('estimate' in window.navigator.storage);
- assert_equals(typeof window.navigator.storage.estimate, 'function');
- assert_true(window.navigator.storage.estimate() instanceof Promise);
-}, 'estimate() method exists and returns a Promise');
-
-promise_test(function(t) {
- return window.navigator.storage.estimate().then(function(result) {
- assert_true(typeof result === 'object');
- assert_true('usage' in result);
- assert_equals(typeof result.usage, 'number');
- assert_true('quota' in result);
- assert_equals(typeof result.quota, 'number');
- });
-}, 'estimate() resolves to dictionary with members');
-
-
-// Simple Promise wrappers for IndexedDB to make async testing easier.
-function deleteDB(name) {
- return new Promise(function(resolve, reject) {
- var del = indexedDB.deleteDatabase(name);
- del.onerror = function() { reject(del.error); };
- del.onsuccess = function() { resolve(); };
- });
-}
-function openDB(name, upgrade) {
- return new Promise(function(resolve, reject) {
- var open = indexedDB.open(name);
- open.onerror = function() { reject(open.error); };
- open.onupgradeneeded = function() { upgrade(open.result); };
- open.onsuccess = function() { resolve(open.result); };
- });
-}
-function transactionToPromise(tx) {
- return new Promise(function(resolve, reject) {
- tx.onabort = function() { reject(tx.error); };
- tx.oncomplete = function() { resolve(); };
- });
-}
-
-promise_test(function(t) {
- var large_value = new Uint8Array(1e6);
- var dbname = 'db' + window.location;
- var db, before, after;
-
- return deleteDB(name)
- .then(() => openDB(name, db => { db.createObjectStore('store'); }))
- .then(connection => {
- db = connection;
- return navigator.storage.estimate();
- })
- .then(estimate => {
- before = estimate.usage;
- var tx = db.transaction('store', 'readwrite');
- tx.objectStore('store').put(large_value, 'k');
- return transactionToPromise(tx);
- })
- .then(() => {
- return navigator.storage.estimate();
- })
- .then(estimate => {
- after = estimate.usage;
- assert_greater_than(after, before,
- 'estimated usage should increase');
- // This assertion may not hold, e.g. if the implementation compresses
- // the data or pre-allocate blocks larger than the value being stored.
- assert_greater_than_equal(after - before, large_value.length,
- 'increase should be at least as large as value stored');
-
- db.close();
- return deleteDB(name);
- });
-}, 'estimate() shows usage increase after large value is stored');
-
-</script>
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/storage/storagemanager-estimate.https.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698