mirror of
https://github.com/servo/servo.git
synced 2025-08-29 17:18:23 +01:00
Update web-platform-tests to revision 7a767a52741f628430ffbbed46e7f3df68ba3534
Fixes #15648.
This commit is contained in:
parent
a1e4c547f0
commit
4fadf9b0b6
1184 changed files with 22551 additions and 9856 deletions
111
tests/wpt/web-platform-tests/webstorage/event_no_duplicates.html
Normal file
111
tests/wpt/web-platform-tests/webstorage/event_no_duplicates.html
Normal file
|
@ -0,0 +1,111 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<title>WebStorage Test: StorageEvent - only if something changes</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body>
|
||||
<script>
|
||||
const iframe = document.createElement('iframe');
|
||||
|
||||
function tests(storageName) {
|
||||
test(t => assert_true(storageName in window), storageName + ' exists');
|
||||
|
||||
const storage = window[storageName];
|
||||
const iframeStorage = iframe.contentWindow[storageName];
|
||||
|
||||
add_completion_callback(() => {
|
||||
storage.clear();
|
||||
});
|
||||
|
||||
promise_test(t => {
|
||||
const w = new EventWatcher(t, iframe.contentWindow, 'storage');
|
||||
|
||||
// Random key to make sure we don't conflict with any cruft leftover from
|
||||
// earlier runs. Any synchronization would be really hard with localStorage
|
||||
// limited guarantees.
|
||||
const testKey = Math.random().toString(36).slice(2);
|
||||
|
||||
storage.setItem(testKey, 'foo');
|
||||
storage.setItem(testKey, 'foo');
|
||||
storage.setItem(testKey, 'bar');
|
||||
return w.wait_for('storage')
|
||||
.then(e => {
|
||||
assert_equals(e.storageArea, iframeStorage);
|
||||
assert_equals(e.key, testKey);
|
||||
assert_equals(e.newValue, 'foo');
|
||||
return w.wait_for('storage');
|
||||
})
|
||||
.then(e => {
|
||||
assert_equals(e.storageArea, iframeStorage);
|
||||
assert_equals(e.key, testKey);
|
||||
assert_equals(e.oldValue, 'foo');
|
||||
assert_equals(e.newValue, 'bar');
|
||||
});
|
||||
}, 'Setting to same value does not trigger event for ' + storageName);
|
||||
|
||||
promise_test(t => {
|
||||
const w = new EventWatcher(t, iframe.contentWindow, 'storage');
|
||||
|
||||
// Random key to make sure we don't conflict with any cruft leftover from
|
||||
// earlier runs. Any synchronization would be really hard with localStorage
|
||||
// limited guarantees.
|
||||
const testKey1 = Math.random().toString(36).slice(2);
|
||||
const testKey2 = Math.random().toString(36).slice(2);
|
||||
|
||||
storage.removeItem(testKey1);
|
||||
storage.setItem(testKey2, 'foo');
|
||||
return w.wait_for('storage')
|
||||
.then(e => {
|
||||
assert_equals(e.storageArea, iframeStorage);
|
||||
assert_equals(e.key, testKey2);
|
||||
assert_equals(e.newValue, 'foo');
|
||||
});
|
||||
}, 'Deleting non-existent key does not trigger event for ' + storageName);
|
||||
|
||||
|
||||
promise_test(t => {
|
||||
const w = new EventWatcher(t, iframe.contentWindow, 'storage');
|
||||
|
||||
// Random key to make sure we don't conflict with any cruft leftover from
|
||||
// earlier runs. Any synchronization would be really hard with localStorage
|
||||
// limited guarantees.
|
||||
const testKey = Math.random().toString(36).slice(2);
|
||||
|
||||
storage.setItem(testKey, 'foo');
|
||||
storage.clear();
|
||||
storage.clear();
|
||||
storage.setItem(testKey, 'bar');
|
||||
return w.wait_for('storage')
|
||||
.then(e => {
|
||||
assert_equals(e.storageArea, iframeStorage);
|
||||
assert_equals(e.key, testKey);
|
||||
assert_equals(e.newValue, 'foo');
|
||||
return w.wait_for('storage');
|
||||
})
|
||||
.then(e => {
|
||||
assert_equals(e.storageArea, iframeStorage);
|
||||
assert_equals(e.key, null);
|
||||
assert_equals(e.oldValue, null);
|
||||
assert_equals(e.newValue, null);
|
||||
return w.wait_for('storage');
|
||||
})
|
||||
.then(e => {
|
||||
assert_equals(e.storageArea, iframeStorage);
|
||||
assert_equals(e.key, testKey);
|
||||
assert_equals(e.oldValue, null);
|
||||
assert_equals(e.newValue, 'bar');
|
||||
});
|
||||
}, 'Clearing empty storage does not trigger event for ' + storageName);
|
||||
|
||||
}
|
||||
|
||||
iframe.onload = () => {
|
||||
tests('sessionStorage');
|
||||
tests('localStorage');
|
||||
};
|
||||
iframe.src = 'about:blank';
|
||||
document.body.appendChild(iframe);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue