1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/localstorage/test_storageConstructor.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<head> 1.6 +<title>Storage interface</title> 1.7 + 1.8 +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.10 + 1.11 +<script type="text/javascript"> 1.12 + 1.13 +function startTest() 1.14 +{ 1.15 + var functionCalled = false; 1.16 + is(localStorage instanceof Storage, true, "localStorage is instance of Storage"); 1.17 + Storage.prototype.exists = function(key) { 1.18 + functionCalled = true; 1.19 + return this.getItem(key) != null; 1.20 + } 1.21 + localStorage.setItem("test_prototype", "value"); 1.22 + is(functionCalled, false, "Overridden function not called"); 1.23 + is(localStorage.exists("test_prototype"), true, "Prototype overridden"); 1.24 + is(functionCalled, true, "Overridden function called"); 1.25 + localStorage.clear(); 1.26 + 1.27 + SimpleTest.finish(); 1.28 +} 1.29 + 1.30 +SimpleTest.waitForExplicitFinish(); 1.31 + 1.32 +</script> 1.33 + 1.34 +</head> 1.35 + 1.36 +<body onload="startTest();"> 1.37 +</body> 1.38 +</html>