browser_permissionsPromptWorker.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/
  4. */
  5. const testWorkerURL = "http://mochi.test:8888/browser/" +
  6. "dom/indexedDB/test/browser_permissionsWorker.html";
  7. const testSharedWorkerURL = "http://mochi.test:8888/browser/" +
  8. "dom/indexedDB/test/browser_permissionsSharedWorker.html";
  9. const notificationID = "indexedDB-permissions-prompt";
  10. function test()
  11. {
  12. waitForExplicitFinish();
  13. executeSoon(test1);
  14. }
  15. function test1()
  16. {
  17. // We want a prompt.
  18. removePermission(testWorkerURL, "indexedDB");
  19. info("creating tab");
  20. gBrowser.selectedTab = gBrowser.addTab();
  21. gBrowser.selectedBrowser.addEventListener("load", function () {
  22. gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
  23. setFinishedCallback(function(isIDBDatabase, exception) {
  24. ok(isIDBDatabase, "First database creation was successful");
  25. ok(!exception, "No exception");
  26. is(getPermission(testWorkerURL, "indexedDB"),
  27. Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
  28. "Correct permission set");
  29. gBrowser.removeCurrentTab();
  30. executeSoon(test2);
  31. });
  32. registerPopupEventHandler("popupshowing", function () {
  33. ok(true, "prompt showing");
  34. });
  35. registerPopupEventHandler("popupshown", function () {
  36. ok(true, "prompt shown");
  37. triggerMainCommand(this);
  38. });
  39. registerPopupEventHandler("popuphidden", function () {
  40. ok(true, "prompt hidden");
  41. });
  42. }, true);
  43. info("loading test page: " + testWorkerURL);
  44. content.location = testWorkerURL;
  45. }
  46. function test2()
  47. {
  48. // We want a prompt.
  49. removePermission(testSharedWorkerURL, "indexedDB");
  50. info("creating tab");
  51. gBrowser.selectedTab = gBrowser.addTab();
  52. gBrowser.selectedBrowser.addEventListener("load", function () {
  53. gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
  54. setFinishedCallback(function(isIDBDatabase, exception) {
  55. ok(!isIDBDatabase, "First database creation was successful");
  56. ok(exception, "No exception");
  57. is(getPermission(testSharedWorkerURL, "indexedDB"),
  58. Components.interfaces.nsIPermissionManager.UNKNOWN_ACTION,
  59. "Correct permission set");
  60. gBrowser.removeCurrentTab();
  61. executeSoon(finish);
  62. });
  63. registerPopupEventHandler("popupshowing", function () {
  64. ok(false, "prompt showing");
  65. });
  66. registerPopupEventHandler("popupshown", function () {
  67. ok(false, "prompt shown");
  68. });
  69. registerPopupEventHandler("popuphidden", function () {
  70. ok(false, "prompt hidden");
  71. });
  72. }, true);
  73. info("loading test page: " + testSharedWorkerURL);
  74. content.location = testSharedWorkerURL;
  75. }