test_bfcache.html 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <!--
  2. Any copyright is dedicated to the Public Domain.
  3. http://creativecommons.org/publicdomain/zero/1.0/
  4. -->
  5. <html>
  6. <head>
  7. <title>Indexed Database Property Test</title>
  8. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  10. <script type="text/javascript;version=1.7">
  11. var gOrigMaxTotalViewers = undefined;
  12. function setCachePref(enabled) {
  13. if (enabled) {
  14. is(typeof gOrigMaxTotalViewers, "undefined",
  15. "don't double-enable bfcache");
  16. SpecialPowers.setBoolPref("browser.sessionhistory.cache_subframes",
  17. true);
  18. gOrigMaxTotalViewers =
  19. SpecialPowers.getIntPref("browser.sessionhistory.max_total_viewers");
  20. SpecialPowers.setIntPref("browser.sessionhistory.max_total_viewers",
  21. 10);
  22. }
  23. else {
  24. is(typeof gOrigMaxTotalViewers, "number",
  25. "don't double-disable bfcache");
  26. SpecialPowers.setIntPref("browser.sessionhistory.max_total_viewers",
  27. gOrigMaxTotalViewers);
  28. gOrigMaxTotalViewers = undefined;
  29. try {
  30. SpecialPowers.clearUserPref("browser.sessionhistory.cache_subframes");
  31. } catch (e) { /* Pref didn't exist, meh */ }
  32. }
  33. }
  34. function testSteps()
  35. {
  36. var iframe = $("iframe");
  37. setCachePref(true);
  38. window.onmessage = grabEventAndContinueHandler;
  39. iframe.src = "bfcache_iframe1.html";
  40. var event = yield undefined;
  41. is(event.data, "go", "set up database successfully");
  42. iframe.src = "bfcache_iframe2.html";
  43. res = JSON.parse((yield).data);
  44. is(res.version, 2, "version was set correctly");
  45. is(res.storeCount, 1, "correct set of stores");
  46. ok(!("blockedFired" in res), "blocked shouldn't fire");
  47. is(res.value, JSON.stringify({ hello: "world" }),
  48. "correct value found in store");
  49. setCachePref(false);
  50. finishTest();
  51. yield undefined;
  52. }
  53. </script>
  54. <script type="text/javascript;version=1.7" src="helpers.js"></script>
  55. </head>
  56. <body onload="runTest();">
  57. <iframe id="iframe"></iframe>
  58. </body>
  59. </html>