GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — localStorage/tests.html at master · machao/localStorage
This repository was archived by the owner on Jun 27, 2021. It is now read-only.
Expand file tree/ Copy pathtests.htmlMore file actions 95 lines (87 loc) · 2.13 KB / Copy pathtests.htmlFile metadata and controls95 lines (87 loc) · 2.13 KB 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>localStorage 测试用例</title> <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css"> <script src="storage.js"></script> <script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script> </head> <body> <div id="qunit"></div> <div id="qunit-fixture"></div> <script> test( "本地存储 window.LS 测试", 8, function() { var w = function(key, value){ window.LS.set(key, value); }; var r = function(key){ return window.LS.get(key); }; var undefined, rnd = (+new Date())+""; w("a", rnd); ok( r("a") == rnd, "简单的读写" ); w("1a", "1a"); ok( r("1a") == "1a", "以数字开头的key读写测试" ); w("~!@#$%^&*()_+=-`,./\?><|{}[]", "hello"); ok( r("~!@#$%^&*()_+=-`,./\?><|{}[]") == "hello", "包含特殊字符的key读写测试" ); window.LS.remove("a"); ok( r("a") == undefined, "remove测试"); window.LS.clear(); ok( window.LS.length == 0 && r("1a") == undefined, "clear测试" ); var testLength = function(){ window.LS.clear(); if( window.LS.length == 0 ){ w("a", "a"); if( window.LS.length == 1 ){ w("b", "b"); if( window.LS.length == 2 ){ window.LS.remove("a"); if( window.LS.length == 1 ){ return true; } } } } return false; } ok( testLength(), "length属性测试" ); var testEach = function(){ var i = 0, result = { "a" : "a", "b" : "b", "c" : "c" }; window.LS.clear(); w("a", "a"); w("b", "b"); w("c", "c"); window.LS.each(function(k, v){ if( result[k] == v ){ i ++; delete result[k]; } }); return i == 3; } ok( testEach(), "each方法测试" ); function testObj(){ var i = 0, result = { "a" : "a", "b" : "b", "c" : "c" }; window.LS.clear(); w("a", "a"); w("b", "b"); w("c", "c"); var obj = window.LS.obj(); for(var k in obj){ if( result[k] == obj[k] ){ i ++; delete result[k]; } } return i == 3; } ok( testObj(), "obj方法测试"); }); </script> </body> </html> |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |