browser_permissionsPromptAllow.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. // We want a prompt.
  12. removePermission(testPageURL, "indexedDB");
  13. executeSoon(test1);
  14. }
  15. function test1()
  16. {
  17. info("creating tab");
  18. gBrowser.selectedTab = gBrowser.addTab();
  19. gBrowser.selectedBrowser.addEventListener("load", function () {
  20. gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
  21. setFinishedCallback(function(isIDBDatabase, exception) {
  22. ok(isIDBDatabase,
  23. "First database creation was successful");
  24. ok(!exception, "No exception");
  25. is(getPermission(testPageURL, "indexedDB"),
  26. Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
  27. "Correct permission set");
  28. gBrowser.removeCurrentTab();
  29. executeSoon(test2);
  30. });
  31. registerPopupEventHandler("popupshowing", function () {
  32. ok(true, "prompt showing");
  33. });
  34. registerPopupEventHandler("popupshown", function () {
  35. ok(true, "prompt shown");
  36. triggerMainCommand(this);
  37. });
  38. registerPopupEventHandler("popuphidden", function () {
  39. ok(true, "prompt hidden");
  40. });
  41. }, true);
  42. info("loading test page: " + testPageURL);
  43. content.location = testPageURL;
  44. }
  45. function test2()
  46. {
  47. info("creating tab");
  48. gBrowser.selectedTab = gBrowser.addTab();
  49. gBrowser.selectedBrowser.addEventListener("load", function () {
  50. gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
  51. setFinishedCallback(function(isIDBDatabase, exception) {
  52. ok(isIDBDatabase,
  53. "First database creation was successful");
  54. ok(!exception, "No exception");
  55. is(getPermission(testPageURL, "indexedDB"),
  56. Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
  57. "Correct permission set");
  58. gBrowser.removeCurrentTab();
  59. unregisterAllPopupEventHandlers();
  60. removePermission(testPageURL, "indexedDB");
  61. executeSoon(finish);
  62. });
  63. registerPopupEventHandler("popupshowing", function () {
  64. ok(false, "Shouldn't show a popup this time");
  65. });
  66. registerPopupEventHandler("popupshown", function () {
  67. ok(false, "Shouldn't show a popup this time");
  68. });
  69. registerPopupEventHandler("popuphidden", function () {
  70. ok(false, "Shouldn't show a popup this time");
  71. });
  72. }, true);
  73. info("loading test page: " + testPageURL);
  74. content.location = testPageURL;
  75. }