Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /** |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | const testPageURL = "http://mochi.test:8888/browser/" + |
michael@0 | 7 | "dom/indexedDB/test/browser_permissionsPrompt.html"; |
michael@0 | 8 | const notificationID = "indexedDB-permissions-prompt"; |
michael@0 | 9 | |
michael@0 | 10 | function test() |
michael@0 | 11 | { |
michael@0 | 12 | waitForExplicitFinish(); |
michael@0 | 13 | |
michael@0 | 14 | PopupNotifications.transitionsEnabled = false; |
michael@0 | 15 | |
michael@0 | 16 | // We want a prompt. |
michael@0 | 17 | setPermission(testPageURL, "indexedDB", "allow"); |
michael@0 | 18 | executeSoon(test1); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | function test1() |
michael@0 | 22 | { |
michael@0 | 23 | info("creating tab"); |
michael@0 | 24 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 25 | |
michael@0 | 26 | gBrowser.selectedBrowser.addEventListener("load", function () { |
michael@0 | 27 | gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 28 | |
michael@0 | 29 | setFinishedCallback(function(result, exception) { |
michael@0 | 30 | ok(result instanceof IDBDatabase, |
michael@0 | 31 | "First database creation was successful"); |
michael@0 | 32 | ok(!exception, "No exception"); |
michael@0 | 33 | is(getPermission(testPageURL, "indexedDB"), |
michael@0 | 34 | Components.interfaces.nsIPermissionManager.UNKNOWN_ACTION, |
michael@0 | 35 | "Correct permission set"); |
michael@0 | 36 | gBrowser.removeCurrentTab(); |
michael@0 | 37 | executeSoon(test2); |
michael@0 | 38 | }); |
michael@0 | 39 | |
michael@0 | 40 | registerPopupEventHandler("popupshowing", function () { |
michael@0 | 41 | ok(true, "prompt showing"); |
michael@0 | 42 | }); |
michael@0 | 43 | registerPopupEventHandler("popupshown", function () { |
michael@0 | 44 | ok(true, "prompt shown"); |
michael@0 | 45 | triggerMainCommand(this); |
michael@0 | 46 | }); |
michael@0 | 47 | registerPopupEventHandler("popuphidden", function () { |
michael@0 | 48 | ok(true, "prompt hidden"); |
michael@0 | 49 | }); |
michael@0 | 50 | |
michael@0 | 51 | }, true); |
michael@0 | 52 | |
michael@0 | 53 | info("loading test page: " + testPageURL); |
michael@0 | 54 | content.location = testPageURL; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function test2() |
michael@0 | 58 | { |
michael@0 | 59 | info("creating tab"); |
michael@0 | 60 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 61 | |
michael@0 | 62 | gBrowser.selectedBrowser.addEventListener("load", function () { |
michael@0 | 63 | gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 64 | |
michael@0 | 65 | setFinishedCallback(function(result, exception) { |
michael@0 | 66 | ok(result instanceof IDBDatabase, |
michael@0 | 67 | "First database creation was successful"); |
michael@0 | 68 | ok(!exception, "No exception"); |
michael@0 | 69 | is(getPermission(testPageURL, "indexedDB"), |
michael@0 | 70 | Components.interfaces.nsIPermissionManager.UNKNOWN_ACTION, |
michael@0 | 71 | "Correct permission set"); |
michael@0 | 72 | gBrowser.removeCurrentTab(); |
michael@0 | 73 | unregisterAllPopupEventHandlers(); |
michael@0 | 74 | removePermission(testPageURL, "indexedDB"); |
michael@0 | 75 | PopupNotifications.transitionsEnabled = true; |
michael@0 | 76 | executeSoon(finish); |
michael@0 | 77 | }); |
michael@0 | 78 | |
michael@0 | 79 | registerPopupEventHandler("popupshowing", function () { |
michael@0 | 80 | ok(false, "Shouldn't show a popup this time"); |
michael@0 | 81 | }); |
michael@0 | 82 | registerPopupEventHandler("popupshown", function () { |
michael@0 | 83 | ok(false, "Shouldn't show a popup this time"); |
michael@0 | 84 | }); |
michael@0 | 85 | registerPopupEventHandler("popuphidden", function () { |
michael@0 | 86 | ok(false, "Shouldn't show a popup this time"); |
michael@0 | 87 | }); |
michael@0 | 88 | |
michael@0 | 89 | }, true); |
michael@0 | 90 | |
michael@0 | 91 | info("loading test page: " + testPageURL); |
michael@0 | 92 | content.location = testPageURL; |
michael@0 | 93 | } |