Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
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 | Components.utils.import("resource://gre/modules/ForgetAboutSite.jsm"); |
michael@0 | 7 | |
michael@0 | 8 | const domains = [ |
michael@0 | 9 | "mochi.test:8888", |
michael@0 | 10 | "www.example.com" |
michael@0 | 11 | ]; |
michael@0 | 12 | |
michael@0 | 13 | const addPath = "/browser/dom/indexedDB/test/browser_forgetThisSiteAdd.html"; |
michael@0 | 14 | const getPath = "/browser/dom/indexedDB/test/browser_forgetThisSiteGet.html"; |
michael@0 | 15 | |
michael@0 | 16 | const testPageURL1 = "http://" + domains[0] + addPath; |
michael@0 | 17 | const testPageURL2 = "http://" + domains[1] + addPath; |
michael@0 | 18 | const testPageURL3 = "http://" + domains[0] + getPath; |
michael@0 | 19 | const testPageURL4 = "http://" + domains[1] + getPath; |
michael@0 | 20 | |
michael@0 | 21 | function test() |
michael@0 | 22 | { |
michael@0 | 23 | requestLongerTimeout(2); |
michael@0 | 24 | waitForExplicitFinish(); |
michael@0 | 25 | // Avoids the prompt |
michael@0 | 26 | setPermission(testPageURL1, "indexedDB", "unknown"); |
michael@0 | 27 | setPermission(testPageURL2, "indexedDB", "unknown"); |
michael@0 | 28 | executeSoon(test1); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | function test1() |
michael@0 | 32 | { |
michael@0 | 33 | // Set database version for domain 1 |
michael@0 | 34 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 35 | gBrowser.selectedBrowser.addEventListener("load", function () { |
michael@0 | 36 | gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 37 | |
michael@0 | 38 | setFinishedCallback(function(result, exception) { |
michael@0 | 39 | ok(result == 11, "Set version on database in " + testPageURL1); |
michael@0 | 40 | ok(!exception, "No exception"); |
michael@0 | 41 | gBrowser.removeCurrentTab(); |
michael@0 | 42 | |
michael@0 | 43 | executeSoon(test2); |
michael@0 | 44 | }); |
michael@0 | 45 | }, true); |
michael@0 | 46 | content.location = testPageURL1; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function test2() |
michael@0 | 50 | { |
michael@0 | 51 | // Set database version for domain 2 |
michael@0 | 52 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 53 | gBrowser.selectedBrowser.addEventListener("load", function () { |
michael@0 | 54 | gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 55 | |
michael@0 | 56 | setFinishedCallback(function(result, exception) { |
michael@0 | 57 | ok(result == 11, "Set version on database in " + testPageURL2); |
michael@0 | 58 | ok(!exception, "No exception"); |
michael@0 | 59 | gBrowser.removeCurrentTab(); |
michael@0 | 60 | |
michael@0 | 61 | executeSoon(test3); |
michael@0 | 62 | }); |
michael@0 | 63 | }, true); |
michael@0 | 64 | content.location = testPageURL2; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | function test3() |
michael@0 | 68 | { |
michael@0 | 69 | // Remove database from domain 2 |
michael@0 | 70 | ForgetAboutSite.removeDataFromDomain(domains[1]); |
michael@0 | 71 | setPermission(testPageURL4, "indexedDB", "unknown"); |
michael@0 | 72 | executeSoon(test4); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | function test4() |
michael@0 | 76 | { |
michael@0 | 77 | // Get database version for domain 1 |
michael@0 | 78 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 79 | gBrowser.selectedBrowser.addEventListener("load", function () { |
michael@0 | 80 | gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 81 | |
michael@0 | 82 | setFinishedCallback(function(result, exception) { |
michael@0 | 83 | ok(result == 11, "Got correct version on database in " + testPageURL3); |
michael@0 | 84 | ok(!exception, "No exception"); |
michael@0 | 85 | gBrowser.removeCurrentTab(); |
michael@0 | 86 | |
michael@0 | 87 | executeSoon(test5); |
michael@0 | 88 | }); |
michael@0 | 89 | }, true); |
michael@0 | 90 | content.location = testPageURL3; |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | function test5() |
michael@0 | 94 | { |
michael@0 | 95 | // Get database version for domain 2 |
michael@0 | 96 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 97 | gBrowser.selectedBrowser.addEventListener("load", function () { |
michael@0 | 98 | gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 99 | |
michael@0 | 100 | setFinishedCallback(function(result, exception) { |
michael@0 | 101 | ok(result == 1, "Got correct version on database in " + testPageURL4); |
michael@0 | 102 | ok(!exception, "No exception"); |
michael@0 | 103 | gBrowser.removeCurrentTab(); |
michael@0 | 104 | |
michael@0 | 105 | executeSoon(finish); |
michael@0 | 106 | }); |
michael@0 | 107 | }, true); |
michael@0 | 108 | content.location = testPageURL4; |
michael@0 | 109 | } |