page_localstorage_snapshotting.html (1393B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <script> 6 /** 7 * Helper page used by browser_localStorage_snapshotting.js. 8 * 9 * We expose methods to be invoked by ContentTask.spawn() calls. 10 * 11 */ 12 var pageName = document.location.search.substring(1); 13 window.addEventListener( 14 "load", 15 () => { document.getElementById("pageNameH").textContent = pageName; }); 16 17 function applyMutations(mutations) { 18 mutations.forEach(function([key, value]) { 19 if (key !== null) { 20 if (value === null) { 21 localStorage.removeItem(key); 22 } else { 23 localStorage.setItem(key, value); 24 } 25 } else { 26 localStorage.clear(); 27 } 28 }); 29 } 30 31 function getState() { 32 let state = {}; 33 let length = localStorage.length; 34 for (let index = 0; index < length; index++) { 35 let key = localStorage.key(index); 36 state[key] = localStorage.getItem(key); 37 } 38 return state; 39 } 40 41 function getKeys() { 42 return Object.keys(localStorage); 43 } 44 45 function beginExplicitSnapshot() { 46 localStorage.beginExplicitSnapshot(); 47 } 48 49 function checkpointExplicitSnapshot() { 50 localStorage.checkpointExplicitSnapshot(); 51 } 52 53 function endExplicitSnapshot() { 54 localStorage.endExplicitSnapshot(); 55 } 56 57 function getHasSnapshot() { 58 return localStorage.hasSnapshot; 59 } 60 61 function getSnapshotUsage() { 62 return localStorage.snapshotUsage; 63 } 64 65 </script> 66 </head> 67 <body><h2 id="pageNameH"></h2></body> 68 </html>