summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webstorage/storage_local_setitem_quotaexceedederr.html
blob: b547f3046d1918f5625a85b05963785c441bae58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE HTML>
<html>
 <head>
  <title>WebStorage Test: localStorage - setItem throws QuotaExceededError</title>
  <meta name="timeout" content="long">
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
 </head>
 <body>
    <h1>storage_local_setItem_QUOTA_EXCEEDED_ERR</h1>
    <div id="log"></div>
    <script>
        test(function() {
            localStorage.clear();

            var index = 0;
            var key = "name";
            var val = "x".repeat(1024);

            assert_throws("QUOTA_EXCEEDED_ERR", function() {
                while (true) {
                    index++;
                    localStorage.setItem("" + key + index, "" + val + index);
                }
            });

            localStorage.clear();
        }, "Throws QuotaExceededError when the quota has been exceeded");
    </script>
 </body>
</html>