browser_perwindow_privateBrowsing.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/
  4. */
  5. const testPageURL = "http://mochi.test:8888/browser/" +
  6. "dom/indexedDB/test/browser_permissionsPrompt.html";
  7. const notificationID = "indexedDB-permissions-prompt";
  8. function test()
  9. {
  10. waitForExplicitFinish();
  11. // Avoids the actual prompt
  12. setPermission(testPageURL, "indexedDB");
  13. executeSoon(test1);
  14. }
  15. function test1()
  16. {
  17. gBrowser.selectedTab = gBrowser.addTab();
  18. gBrowser.selectedBrowser.addEventListener("load", function () {
  19. if (content.location != testPageURL) {
  20. content.location = testPageURL;
  21. return;
  22. }
  23. gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
  24. setFinishedCallback(function(isIDBDatabase, exception) {
  25. ok(isIDBDatabase,
  26. "First database creation was successful");
  27. ok(!exception, "No exception");
  28. gBrowser.removeCurrentTab();
  29. executeSoon(test2);
  30. });
  31. }, true);
  32. content.location = testPageURL;
  33. }
  34. function test2()
  35. {
  36. var win = OpenBrowserWindow({private: true});
  37. win.addEventListener("load", function onLoad() {
  38. win.removeEventListener("load", onLoad, false);
  39. executeSoon(() => test3(win));
  40. }, false);
  41. registerCleanupFunction(() => win.close());
  42. }
  43. function test3(win)
  44. {
  45. win.gBrowser.selectedTab = win.gBrowser.addTab();
  46. win.gBrowser.selectedBrowser.addEventListener("load", function () {
  47. if (win.content.location != testPageURL) {
  48. win.content.location = testPageURL;
  49. return;
  50. }
  51. win.gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
  52. setFinishedCallback(function(isIDBDatabase, exception) {
  53. ok(!isIDBDatabase, "No database");
  54. is(exception, "InvalidStateError", "Correct exception");
  55. win.gBrowser.removeCurrentTab();
  56. executeSoon(finish);
  57. }, win);
  58. }, true);
  59. win.content.location = testPageURL;
  60. }