event_session_newvalue.html (1367B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>WebStorage Test: sessionStorage event - newValue</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 </head> 8 <body> 9 <h1>event_session_newValue</h1> 10 <div id="log"></div> 11 <script> 12 async_test(function(t) { 13 sessionStorage.clear(); 14 t.add_cleanup(function() { sessionStorage.clear() }); 15 16 self.fail = t.step_func(function(msg) { 17 assert_unreached(msg); 18 t.done(); 19 }); 20 21 var expected = ['user1', 'user2', null] 22 function onStorageEvent(event) { 23 t.step(function() { 24 assert_equals(event.newValue, expected.shift()); 25 }); 26 if (!expected.length) { 27 t.done(); 28 } 29 } 30 31 window.addEventListener('storage', t.step_func(onStorageEvent), false); 32 33 var el = document.createElement("iframe"); 34 el.setAttribute('id', 'ifrm'); 35 el.setAttribute('src', 'resources/session_change_item_iframe.html'); 36 document.body.appendChild(el); 37 }, "newvalue property test of session event - Session event is fired due to an invocation of the setItem(), clear() methods."); 38 </script> 39 </body> 40 </html>