Home | History | Annotate | Download | only in indexeddb
      1 <!DOCTYPE html>
      2 <html>
      3 <!--
      4   Copyright (c) 2013 The Chromium Authors. All rights reserved.
      5   Use of this source code is governed by a BSD-style license that can be
      6   found in the LICENSE file.
      7 -->
      8 <head>
      9 <title>IDB test that origins over quota aren't trapped</title>
     10 <script type="text/javascript" src="common.js"></script>
     11 </head>
     12 <script>
     13   function test() {
     14     // This file runs after fill_up_5k puts this origin over quota.
     15     request = indexedDB.open("fill_up_5k.html");
     16     request.onblocked = unexpectedBlockedCallback;
     17     request.onupgradeneeded = unexpectedUpgradeNeededCallback;
     18     request.onsuccess = onOpen;
     19     request.onerror = unexpectedErrorCallback;
     20   }
     21 
     22   function onOpen() {
     23     db = event.target.result;
     24     shouldBe("db.objectStoreNames.length", "1");
     25     trans = db.transaction(db.objectStoreNames, "readwrite");
     26     trans.objectStore(db.objectStoreNames[0]).put("dogs", "cats");
     27     trans.oncomplete = unexpectedCompleteCallback;
     28     trans.onabort = function() {
     29       shouldBeEqualToString("trans.error.name", "QuotaExceededError");
     30       testOnlyDeleteTransaction();
     31     }
     32   }
     33 
     34   function testOnlyDeleteTransaction() {
     35     trans = db.transaction(db.objectStoreNames, "readwrite");
     36     request = trans.objectStore(db.objectStoreNames[0]).openCursor();
     37     request.onerror = unexpectedErrorCallback;
     38     request.onsuccess = function() {
     39       cursor = request.result;
     40       shouldBeTrue("cursor != null");
     41       cursor.delete();
     42     }
     43     trans.onabort = unexpectedAbortCallback;
     44     trans.oncomplete = testReadOnlyTransaction;
     45   }
     46 
     47   function testReadOnlyTransaction() {
     48     trans = db.transaction(db.objectStoreNames, "readonly");
     49     trans.objectStore(db.objectStoreNames[0]).get("cats").onerror =
     50         unexpectedErrorCallback;
     51     trans.onabort = unexpectedAbortCallback;
     52     trans.oncomplete = done;
     53   }
     54 
     55 </script>
     56 <body onLoad="test()">
     57 <div id="status">Starting...</div>
     58 </body>
     59 </html>
     60