https://github.com/web-platform-tests/wpt
Raw File
Tip revision: f3eea8d31d07201e4ada8203be7e4d1ee5227697 authored by Robin Berjon on 09 December 2013, 16:11:17 UTC
import latest tests from html5lib-tests; including new-ruby tests (in html/syntax/parsing/html5lib_tests19.html)
Tip revision: f3eea8d
idbcursor_continue_index3.htm
<!DOCTYPE html>
<html>
<head>
    <title>IDBCursor.continue() - index - attempt to iterate to the previous record when the direction is set for the next record </title>
    <script type="text/javascript" src="support.js"></script>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <script type="text/javascript">
        var objectStoreName = "objectstore";
        var indexName = "index";
        var records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" },
                        { pKey: "primaryKey_1", iKey: "indexKey_1" }];
        var db = null;
        var t = async_test(); 
        
        function RunTest() {
            var rqOpen = window.indexedDB.open(databaseName, databaseVersion);
            rqOpen.onupgradeneeded = t.step_func( function (event) {
                db = event.target.result;
                db.onerror = t.step_func( assert_database_error );
                var objStore = db.createObjectStore(objectStoreName, {keyPath:"pKey"});
                objStore.createIndex(indexName, "iKey");
                for(var i = 0; i < records.length; i++) {
                    objStore.add(records[i]);
                }
            });
            rqOpen.onsuccess = t.step_func( VerifyCursorThrowsException );
            rqOpen.onerror = t.step_func( assert_open_request_error );
        }
            
        function VerifyCursorThrowsException(event) {
            var txn = db.transaction(objectStoreName, "readonly");
            var objStore = txn.objectStore(objectStoreName);
            var index = objStore.index(indexName);
            var rqCursor = index.openCursor();
            rqCursor.onsuccess = t.step_func( function(event) {
                var cursor = event.target.result;
                assert_cursor_exists(cursor);
                try {
                    cursor.continue(records[0].iKey);
                } catch(ex) {
                    assert_equals(ex.name, "DataError", "ex.name");
                    t.done();
                    return;
                }
                assert_expected_exception();
            });
        }
        
        add_completion_callback(function() { if(db) db.close(); });
        
        setup(function() {
            var rqDelete = window.indexedDB.deleteDatabase(databaseName);
            rqDelete.onsuccess = t.step_func( RunTest );
        });
    </script>
</head>
<body>
    <div id="log"></div>
</body>
</html>
back to top