Created
March 27, 2013 17:17
-
-
Save jsantell/5256189 to your computer and use it in GitHub Desktop.
Jetpack page-mod/bfcache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* testing page-mod's persistence with bfcache | |
*/ | |
require('sdk/page-mod').PageMod({ | |
include: '*', | |
contentScript: 'new ' + fn | |
}); | |
// Content script | |
function fn () { | |
var count = 0; | |
console.log("load: " + document.location.href); | |
setInterval(function () { | |
++count; | |
console.log("ping " + count + ": " + document.location.href); | |
}, 3000); | |
} | |
/* | |
Output: Loading `products` page, then clicking on `about`, | |
going "back" to `products` and then "forward" to `about`, | |
persisting counts and pings without reloading | |
info: pagemod: load: http://www.mozilla.org/en-US/products/ | |
info: pagemod: ping 1: http://www.mozilla.org/en-US/products/ | |
info: pagemod: ping 2: http://www.mozilla.org/en-US/products/ | |
info: pagemod: ping 3: http://www.mozilla.org/en-US/products/ | |
info: pagemod: load: http://www.mozilla.org/en-US/about/ | |
info: pagemod: ping 1: http://www.mozilla.org/en-US/about/ | |
info: pagemod: ping 2: http://www.mozilla.org/en-US/about/ | |
info: pagemod: ping 3: http://www.mozilla.org/en-US/about/ | |
info: pagemod: ping 4: http://www.mozilla.org/en-US/products/ | |
info: pagemod: ping 5: http://www.mozilla.org/en-US/products/ | |
info: pagemod: ping 6: http://www.mozilla.org/en-US/products/ | |
info: pagemod: ping 4: http://www.mozilla.org/en-US/about/ | |
info: pagemod: ping 5: http://www.mozilla.org/en-US/about/ | |
info: pagemod: ping 6: http://www.mozilla.org/en-US/about/ | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment