Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 | executeSoon(test1); |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | function test1() |
michael@0 | 17 | { |
michael@0 | 18 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 19 | gBrowser.selectedBrowser.addEventListener("load", function () { |
michael@0 | 20 | if (content.location != testPageURL) { |
michael@0 | 21 | content.location = testPageURL; |
michael@0 | 22 | return; |
michael@0 | 23 | } |
michael@0 | 24 | gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 25 | |
michael@0 | 26 | setFinishedCallback(function(result, exception) { |
michael@0 | 27 | ok(result instanceof IDBDatabase, |
michael@0 | 28 | "First database creation was successful"); |
michael@0 | 29 | ok(!exception, "No exception"); |
michael@0 | 30 | gBrowser.removeCurrentTab(); |
michael@0 | 31 | |
michael@0 | 32 | executeSoon(test2); |
michael@0 | 33 | }); |
michael@0 | 34 | }, true); |
michael@0 | 35 | content.location = testPageURL; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function test2() |
michael@0 | 39 | { |
michael@0 | 40 | var win = OpenBrowserWindow({private: true}); |
michael@0 | 41 | win.addEventListener("load", function onLoad() { |
michael@0 | 42 | win.removeEventListener("load", onLoad, false); |
michael@0 | 43 | executeSoon(function() test3(win)); |
michael@0 | 44 | }, false); |
michael@0 | 45 | registerCleanupFunction(function() win.close()); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function test3(win) |
michael@0 | 49 | { |
michael@0 | 50 | win.gBrowser.selectedTab = win.gBrowser.addTab(); |
michael@0 | 51 | win.gBrowser.selectedBrowser.addEventListener("load", function () { |
michael@0 | 52 | if (win.content.location != testPageURL) { |
michael@0 | 53 | win.content.location = testPageURL; |
michael@0 | 54 | return; |
michael@0 | 55 | } |
michael@0 | 56 | win.gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 57 | |
michael@0 | 58 | setFinishedCallback(function(result, exception) { |
michael@0 | 59 | ok(!result, "No database"); |
michael@0 | 60 | is(exception, "InvalidStateError", "Correct exception"); |
michael@0 | 61 | win.gBrowser.removeCurrentTab(); |
michael@0 | 62 | |
michael@0 | 63 | executeSoon(finish); |
michael@0 | 64 | }, win); |
michael@0 | 65 | }, true); |
michael@0 | 66 | win.content.location = testPageURL; |
michael@0 | 67 | } |