summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/localstorage/test_storageConstructor.html
blob: e0aa4e11dc2af592ba4781d32d4a9bd5c19f3277 (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
32
33
34
35
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Storage interface</title>

<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />

<script type="text/javascript">

function startTest()
{
  var functionCalled = false;
  is(localStorage instanceof Storage, true, "localStorage is instance of Storage");
  Storage.prototype.exists = function(key) {
    functionCalled = true;
    return this.getItem(key) != null;
  }
  localStorage.setItem("test_prototype", "value");
  is(functionCalled, false, "Overridden function not called");
  is(localStorage.exists("test_prototype"), true, "Prototype overridden");
  is(functionCalled, true, "Overridden function called");
  localStorage.clear();
  
  SimpleTest.finish();
}

SimpleTest.waitForExplicitFinish();

</script>

</head>

<body onload="startTest();">
</body>
</html>