| Odin Hørthe Omdal | 41424a7 | 2012-08-15 18:21:14 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <title>IDBTransaction</title> |
| Xie Yunxiao | e027b49 | 2014-04-09 07:20:33 | [diff] [blame^] | 3 | <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal"> |
| Odin Hørthe Omdal | 41424a7 | 2012-08-15 18:21:14 | [diff] [blame] | 4 | <script src="/resources/testharness.js"></script> |
| 5 | <script src="/resources/testharnessreport.js"></script> |
| 6 | <script src="support.js"></script> |
| 7 | |
| 8 | <script> |
| 9 | var db, |
| 10 | t = async_test(document.title + " - request gotten by the handler"), |
| 11 | open_t = async_test(document.title + " - request returned by open()"), |
| 12 | |
| 13 | open_rq = indexedDB.open("idbtransaction-" + new Date().getTime() + Math.random()); |
| 14 | |
| 15 | open_t.step(function() { |
| 16 | assert_equals(open_rq.transaction, null, "IDBOpenDBRequest.transaction"); |
| 17 | assert_equals(open_rq.source, null, "IDBOpenDBRequest.source"); |
| 18 | assert_equals(open_rq.readyState, "pending", "IDBOpenDBRequest.readyState"); |
| 19 | |
| 20 | assert_true(open_rq instanceof IDBOpenDBRequest, "open_rq instanceof IDBOpenDBRequest"); |
| 21 | assert_equals(open_rq + "", "[object IDBOpenDBRequest]", "IDBOpenDBRequest (open_rq)"); |
| 22 | |
| 23 | open_t.done(); |
| 24 | }); |
| 25 | |
| 26 | open_rq.onupgradeneeded = t.step_func(function(e) { |
| 27 | assert_equals(e.target, open_rq, "e.target is reusing the same IDBOpenDBRequest"); |
| 28 | assert_equals(e.target.transaction, open_rq.transaction, "IDBOpenDBRequest.transaction"); |
| 29 | |
| 30 | assert_true(e.target.transaction instanceof IDBTransaction, "transaction instanceof IDBTransaction"); |
| 31 | t.done(); |
| 32 | }); |
| 33 | |
| 34 | |
| 35 | // Not plausible conditions... |
| 36 | function fail_helper(name) { |
| 37 | return function() { |
| 38 | t.step(function() { assert_unreached(name); }); |
| 39 | open_t.step(function() { assert_unreached(name); }); |
| 40 | }; |
| 41 | } |
| 42 | open_rq.onblocked = fail_helper('open_rq.onblocked'); |
| 43 | open_rq.onerror = fail_helper('open_rq.onerror'); |
| 44 | </script> |
| 45 | |
| 46 | <div id="log"></div> |