Revision 31a51c70f74e23dc52f2033e552990a03f3166a9 authored by Mike Pennisi on 29 June 2018, 15:27:58 UTC, committed by Ms2ger on 02 July 2018, 14:31:05 UTC
Today, the return value of functions provided to the global `add_cleanup` function has no effect on the behavior of the test runner. An upcoming feature addition to testharness.js will cause the return value to influence test results [1]. Despite this, some existing tests have already been authored to return a value: the result of `document.exitFullScreen`. Although this is expected to be a Promise in conforming implementations, some browsers do not yet implement this functionality. To allow the new test harness feature to land without introducing harness errors, refactor existing tests to omit a return value. Additionally, use `Promise.prototype.catch` to avoid race conditions resulting from unhandled Promise rejections (which trigger a harness error in testharness.js today). [1] https://github.com/web-platform-tests/wpt/issues/6075
1 parent 21369c1
idbcursor-reused.htm
<!DOCTYPE html>
<title>IDBCursor is reused</title>
<link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
<meta rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBCursor-continue-void-any-key">
<meta rel=assert title="Otherwise this method runs the steps for asynchronously executing a request. However, the steps are slightly modified such that instead of creating a new IDBRequest, it reuses the request originally created when this cursor was created. The done flag on the request is set to false before the request is returned. The steps are run with the cursor's source as source and the steps for iterating a cursor as operation, using this cursor as cursor and the key parameter as key.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
var db
var open_rq = createdb(async_test())
open_rq.onupgradeneeded = function(e) {
db = e.target.result
var os = db.createObjectStore("test")
os.add("data", "k")
os.add("data2", "k2")
}
open_rq.onsuccess = function(e) {
var cursor
var count = 0
var rq = db.transaction("test").objectStore("test").openCursor()
rq.onsuccess = this.step_func(function(e)
{
switch(count)
{
case 0:
cursor = e.target.result
assert_equals(cursor.value, "data", "prequisite cursor.value")
cursor.custom_cursor_value = 1
e.target.custom_request_value = 2
cursor.continue()
break
case 1:
assert_equals(cursor.value, "data2", "prequisite cursor.value")
assert_equals(cursor.custom_cursor_value, 1, "custom cursor value")
assert_equals(e.target.custom_request_value, 2, "custom request value")
cursor.advance(1)
break
case 2:
assert_false(!!e.target.result, "got cursor")
assert_equals(cursor.custom_cursor_value, 1, "custom cursor value")
assert_equals(e.target.custom_request_value, 2, "custom request value")
break
}
count++
})
rq.transaction.oncomplete = this.step_func(function() {
assert_equals(count, 3, "cursor callback runs")
assert_equals(rq.custom_request_value, 2, "variable placed on old IDBRequest")
assert_equals(cursor.custom_cursor_value, 1, "custom cursor value (transaction.complete)")
this.done()
})
}
</script>
<div id="log"></div>
Computing file changes ...