mirror of
https://github.com/servo/servo.git
synced 2025-09-12 07:58:20 +01:00
Update web-platform-tests to revision 58eb04cecbbec2e18531ab440225e38944a9c444
This commit is contained in:
parent
25e8bf69e6
commit
665817d2a6
35333 changed files with 1818077 additions and 16036 deletions
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>StorageManager: estimate() for indexeddb from worker</title>
|
||||
<meta name="help" href="https://storage.spec.whatwg.org/#dom-storagemanager-estimate">
|
||||
<meta name="author" title="Mozilla" href="https://www.mozilla.org">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
fetch_tests_from_worker(new Worker("storage-estimate-indexeddb.js"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>StorageManager: estimate() for indexeddb</title>
|
||||
<meta name="help" href="https://storage.spec.whatwg.org/#dom-storagemanager-estimate">
|
||||
<meta name="author" title="Mozilla" href="https://www.mozilla.org">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script src="storage-estimate-indexeddb.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,79 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>StorageManager API and opaque origins</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
function load_iframe(src, sandbox) {
|
||||
return new Promise(resolve => {
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.onload = () => { resolve(iframe); };
|
||||
if (sandbox)
|
||||
iframe.sandbox = sandbox;
|
||||
iframe.srcdoc = src;
|
||||
iframe.style.display = 'none';
|
||||
document.documentElement.appendChild(iframe);
|
||||
});
|
||||
}
|
||||
|
||||
function wait_for_message(iframe) {
|
||||
return new Promise(resolve => {
|
||||
self.addEventListener('message', function listener(e) {
|
||||
if (e.source === iframe.contentWindow) {
|
||||
resolve(e.data);
|
||||
self.removeEventListener('message', listener);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function make_script(snippet) {
|
||||
return '<script>' +
|
||||
' window.onmessage = () => {' +
|
||||
' try {' +
|
||||
' (' + snippet + ')' +
|
||||
' .then(' +
|
||||
' result => {' +
|
||||
' window.parent.postMessage({result: "no rejection"}, "*");' +
|
||||
' }, ' +
|
||||
' error => {' +
|
||||
' window.parent.postMessage({result: error.name}, "*");' +
|
||||
' });' +
|
||||
' } catch (ex) {' +
|
||||
// Report if not implemented/exposed, rather than time out.
|
||||
' window.parent.postMessage({result: ex.message}, "*");' +
|
||||
' }' +
|
||||
' };' +
|
||||
'<\/script>';
|
||||
}
|
||||
|
||||
['navigator.storage.persist()',
|
||||
'navigator.storage.persisted()',
|
||||
'navigator.storage.estimate()'
|
||||
].forEach(snippet => {
|
||||
promise_test(t => {
|
||||
return load_iframe(make_script(snippet))
|
||||
.then(iframe => {
|
||||
iframe.contentWindow.postMessage({}, '*');
|
||||
return wait_for_message(iframe);
|
||||
})
|
||||
.then(message => {
|
||||
assert_equals(message.result, 'no rejection',
|
||||
`${snippet} should not reject`);
|
||||
});
|
||||
}, `${snippet} in non-sandboxed iframe should not reject`);
|
||||
|
||||
promise_test(t => {
|
||||
return load_iframe(make_script(snippet), 'allow-scripts')
|
||||
.then(iframe => {
|
||||
iframe.contentWindow.postMessage({}, '*');
|
||||
return wait_for_message(iframe);
|
||||
})
|
||||
.then(message => {
|
||||
assert_equals(message.result, 'TypeError',
|
||||
`${snippet} should reject with TypeError`);
|
||||
});
|
||||
}, `${snippet} in sandboxed iframe should reject with TypeError`);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,7 @@
|
|||
importScripts('/resources/testharness.js');
|
||||
|
||||
test(function() {
|
||||
assert_false('persist' in navigator.storage);
|
||||
}, 'navigator.storage.persist should not exist in workers');
|
||||
|
||||
done();
|
|
@ -0,0 +1,13 @@
|
|||
importScripts('/resources/testharness.js');
|
||||
|
||||
promise_test(function() {
|
||||
var promise = navigator.storage.persisted();
|
||||
assert_true(promise instanceof Promise,
|
||||
'navigator.storage.persisted() returned a Promise.');
|
||||
return promise.then(function (result) {
|
||||
assert_equals(typeof result, 'boolean',
|
||||
result + ' should be a boolean');
|
||||
});
|
||||
}, 'navigator.storage.persisted returns a promise that resolves.');
|
||||
|
||||
done();
|
|
@ -0,0 +1,94 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
}
|
||||
|
||||
test(function(t) {
|
||||
assert_true('estimate' in navigator.storage);
|
||||
assert_equals(typeof navigator.storage.estimate, 'function');
|
||||
assert_true(navigator.storage.estimate() instanceof Promise);
|
||||
}, 'estimate() method exists and returns a Promise');
|
||||
|
||||
promise_test(function(t) {
|
||||
return 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');
|
||||
|
||||
promise_test(function(t) {
|
||||
const arraySize = 1e6;
|
||||
const objectStoreName = "storageManager";
|
||||
const dbname = this.window ? window.location.pathname :
|
||||
"estimate-worker.https.html";
|
||||
|
||||
let db;
|
||||
let usageBeforeCreate, usageAfterCreate, usageAfterPut;
|
||||
|
||||
function deleteDB(name) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
let deleteRequest = indexedDB.deleteDatabase(name);
|
||||
deleteRequest.onerror = function() { reject(deleteRequest.error); };
|
||||
deleteRequest.onsuccess = function() { resolve(); };
|
||||
});
|
||||
}
|
||||
|
||||
return deleteDB(dbname)
|
||||
.then(() => {
|
||||
return navigator.storage.estimate();
|
||||
})
|
||||
.then(estimate => {
|
||||
usageBeforeCreate = estimate.usage;
|
||||
return new Promise(function(resolve, reject) {
|
||||
let openRequest = indexedDB.open(dbname);
|
||||
openRequest.onerror = function() { reject(openRequest.error); };
|
||||
openRequest.onupgradeneeded = function(event) {
|
||||
openRequest.result.createObjectStore(objectStoreName);
|
||||
};
|
||||
openRequest.onsuccess = function() { resolve(openRequest.result); };
|
||||
});
|
||||
})
|
||||
.then(connection => {
|
||||
db = connection;
|
||||
return navigator.storage.estimate();
|
||||
})
|
||||
.then(estimate => {
|
||||
usageAfterCreate = estimate.usage;
|
||||
assert_greater_than(usageAfterCreate, usageBeforeCreate,
|
||||
'estimated usage should increase after object store is created');
|
||||
|
||||
let txn = db.transaction(objectStoreName, 'readwrite');
|
||||
let buffer = new ArrayBuffer(arraySize);
|
||||
let view = new Uint8Array(buffer);
|
||||
|
||||
for (let i = 0; i < arraySize; i++) {
|
||||
view[i] = parseInt(Math.random() * 255);
|
||||
}
|
||||
|
||||
let testBlob = new Blob([buffer], {type: "binary/random"});
|
||||
txn.objectStore(objectStoreName).add(testBlob, 1);
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
txn.onabort = function() { reject(txn.error); };
|
||||
txn.oncomplete = function() { resolve(); };
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
return navigator.storage.estimate();
|
||||
})
|
||||
.then(estimate => {
|
||||
usageAfterPut = estimate.usage;
|
||||
assert_greater_than(usageAfterPut, usageAfterCreate,
|
||||
'estimated usage should increase after large value is stored');
|
||||
|
||||
db.close();
|
||||
return deleteDB(dbname)
|
||||
})
|
||||
.then(() => {
|
||||
t.done();
|
||||
})
|
||||
}, 'estimate() shows usage increase after large value is stored');
|
||||
|
||||
done();
|
|
@ -0,0 +1,68 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>StorageManager: estimate()</title>
|
||||
<meta name="help" href="https://storage.spec.whatwg.org/#dom-storagemanager-estimate">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
test(function(t) {
|
||||
assert_true(navigator.storage.estimate() instanceof Promise);
|
||||
}, 'estimate() method returns a Promise');
|
||||
|
||||
promise_test(function(t) {
|
||||
return 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');
|
||||
|
||||
promise_test(function(t) {
|
||||
const large_value = new Uint8Array(1e6);
|
||||
const dbname = `db-${location}-${t.name}`;
|
||||
let db, before, after;
|
||||
|
||||
indexedDB.deleteDatabase(dbname);
|
||||
return new Promise((resolve, reject) => {
|
||||
const open = indexedDB.open(dbname);
|
||||
open.onerror = () => { reject(open.error); };
|
||||
open.onupgradeneeded = () => {
|
||||
const connection = open.result;
|
||||
connection.createObjectStore('store');
|
||||
};
|
||||
open.onsuccess = () => {
|
||||
const connection = open.result;
|
||||
t.add_cleanup(() => {
|
||||
connection.close();
|
||||
indexedDB.deleteDatabase(dbname);
|
||||
});
|
||||
resolve(connection);
|
||||
};
|
||||
})
|
||||
.then(connection => {
|
||||
db = connection;
|
||||
return navigator.storage.estimate();
|
||||
})
|
||||
.then(estimate => {
|
||||
before = estimate.usage;
|
||||
return new Promise((resolve, reject) => {
|
||||
const tx = db.transaction('store', 'readwrite');
|
||||
tx.objectStore('store').put(large_value, 'key');
|
||||
tx.onabort = () => { reject(tx.error); };
|
||||
tx.oncomplete = () => { resolve(); };
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
return navigator.storage.estimate();
|
||||
})
|
||||
.then(estimate => {
|
||||
after = estimate.usage;
|
||||
assert_greater_than(after, before,
|
||||
'estimated usage should increase');
|
||||
});
|
||||
}, 'estimate() shows usage increase after 1MB IndexedDB record is stored');
|
||||
|
||||
</script>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>StorageManager: persist() (worker)</title>
|
||||
<meta name="help" href="https://storage.spec.whatwg.org/#dom-storagemanager-persist">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
var worker = new Worker('resources/storagemanager-persist-worker.js');
|
||||
fetch_tests_from_worker(worker);
|
||||
</script>
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>StorageManager: persist()</title>
|
||||
<meta name="help" href="https://storage.spec.whatwg.org/#dom-storagemanager-persist">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
promise_test(function() {
|
||||
var promise = navigator.storage.persist();
|
||||
assert_true(promise instanceof Promise,
|
||||
'navigator.storage.persist() returned a Promise.');
|
||||
return promise.then(function(result) {
|
||||
assert_equals(typeof result, 'boolean', result + ' should be boolean');
|
||||
});
|
||||
}, 'navigator.storage.persist() returns a promise that resolves.');
|
||||
|
||||
</script>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>StorageManager: persisted() (worker)</title>
|
||||
<meta name="help" href="https://storage.spec.whatwg.org/#dom-storagemanager-persisted">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
var worker = new Worker('resources/storagemanager-persisted-worker.js');
|
||||
fetch_tests_from_worker(worker);
|
||||
</script>
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>StorageManager: persist()</title>
|
||||
<meta name="help" href="https://storage.spec.whatwg.org/#dom-storagemanager-persist">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
promise_test(function() {
|
||||
var promise = navigator.storage.persisted();
|
||||
assert_true(promise instanceof Promise,
|
||||
'navigator.storage.persisted() returned a Promise.');
|
||||
return promise.then(function (result) {
|
||||
assert_equals(typeof result, 'boolean', result + ' should be boolean');
|
||||
});
|
||||
}, 'navigator.storage.persisted() returns a promise that resolves.');
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue