forked from mirrors/gecko-dev
		
	 0640b9ab0f
			
		
	
	
		0640b9ab0f
		
	
	
	
	
		
			
			This uses the pref browser.preferences.useOldOrganization=true to use the old prefs. MozReview-Commit-ID: DQyHYSZJTKd --HG-- rename : browser/components/preferences/in-content/advanced.js => browser/components/preferences/in-content-old/advanced.js rename : browser/components/preferences/in-content/advanced.xul => browser/components/preferences/in-content-old/advanced.xul rename : browser/components/preferences/in-content/applications.js => browser/components/preferences/in-content-old/applications.js rename : browser/components/preferences/in-content/applications.xul => browser/components/preferences/in-content-old/applications.xul rename : browser/components/preferences/in-content/containers.js => browser/components/preferences/in-content-old/containers.js rename : browser/components/preferences/in-content/containers.xul => browser/components/preferences/in-content-old/containers.xul rename : browser/components/preferences/in-content/content.js => browser/components/preferences/in-content-old/content.js rename : browser/components/preferences/in-content/content.xul => browser/components/preferences/in-content-old/content.xul rename : browser/components/preferences/in-content/jar.mn => browser/components/preferences/in-content-old/jar.mn rename : browser/components/preferences/in-content/main.js => browser/components/preferences/in-content-old/main.js rename : browser/components/preferences/in-content/main.xul => browser/components/preferences/in-content-old/main.xul rename : browser/components/preferences/in-content/moz.build => browser/components/preferences/in-content-old/moz.build rename : browser/components/preferences/in-content/preferences.js => browser/components/preferences/in-content-old/preferences.js rename : browser/components/preferences/in-content/preferences.xul => browser/components/preferences/in-content-old/preferences.xul rename : browser/components/preferences/in-content/privacy.js => browser/components/preferences/in-content-old/privacy.js rename : browser/components/preferences/in-content/privacy.xul => browser/components/preferences/in-content-old/privacy.xul rename : browser/components/preferences/in-content/search.js => browser/components/preferences/in-content-old/search.js rename : browser/components/preferences/in-content/search.xul => browser/components/preferences/in-content-old/search.xul rename : browser/components/preferences/in-content/security.js => browser/components/preferences/in-content-old/security.js rename : browser/components/preferences/in-content/security.xul => browser/components/preferences/in-content-old/security.xul rename : browser/components/preferences/in-content/subdialogs.js => browser/components/preferences/in-content-old/subdialogs.js rename : browser/components/preferences/in-content/sync.js => browser/components/preferences/in-content-old/sync.js rename : browser/components/preferences/in-content/sync.xul => browser/components/preferences/in-content-old/sync.xul rename : browser/components/preferences/in-content/tests/.eslintrc.js => browser/components/preferences/in-content-old/tests/.eslintrc.js rename : browser/components/preferences/in-content/tests/browser.ini => browser/components/preferences/in-content-old/tests/browser.ini rename : browser/components/preferences/in-content/tests/browser_advanced_siteData.js => browser/components/preferences/in-content-old/tests/browser_advanced_siteData.js rename : browser/components/preferences/in-content/tests/browser_advanced_update.js => browser/components/preferences/in-content-old/tests/browser_advanced_update.js rename : browser/components/preferences/in-content/tests/browser_applications_selection.js => browser/components/preferences/in-content-old/tests/browser_applications_selection.js rename : browser/components/preferences/in-content/tests/browser_basic_rebuild_fonts_test.js => browser/components/preferences/in-content-old/tests/browser_basic_rebuild_fonts_test.js rename : browser/components/preferences/in-content/tests/browser_bug1018066_resetScrollPosition.js => browser/components/preferences/in-content-old/tests/browser_bug1018066_resetScrollPosition.js rename : browser/components/preferences/in-content/tests/browser_bug1020245_openPreferences_to_paneContent.js => browser/components/preferences/in-content-old/tests/browser_bug1020245_openPreferences_to_paneContent.js rename : browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js => browser/components/preferences/in-content-old/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js rename : browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul => browser/components/preferences/in-content-old/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul rename : browser/components/preferences/in-content/tests/browser_bug410900.js => browser/components/preferences/in-content-old/tests/browser_bug410900.js rename : browser/components/preferences/in-content/tests/browser_bug705422.js => browser/components/preferences/in-content-old/tests/browser_bug705422.js rename : browser/components/preferences/in-content/tests/browser_bug731866.js => browser/components/preferences/in-content-old/tests/browser_bug731866.js rename : browser/components/preferences/in-content/tests/browser_bug795764_cachedisabled.js => browser/components/preferences/in-content-old/tests/browser_bug795764_cachedisabled.js rename : browser/components/preferences/in-content/tests/browser_change_app_handler.js => browser/components/preferences/in-content-old/tests/browser_change_app_handler.js rename : browser/components/preferences/in-content/tests/browser_connection.js => browser/components/preferences/in-content-old/tests/browser_connection.js rename : browser/components/preferences/in-content/tests/browser_connection_bug388287.js => browser/components/preferences/in-content-old/tests/browser_connection_bug388287.js rename : browser/components/preferences/in-content/tests/browser_cookies_exceptions.js => browser/components/preferences/in-content-old/tests/browser_cookies_exceptions.js rename : browser/components/preferences/in-content/tests/browser_defaultbrowser_alwayscheck.js => browser/components/preferences/in-content-old/tests/browser_defaultbrowser_alwayscheck.js rename : browser/components/preferences/in-content/tests/browser_healthreport.js => browser/components/preferences/in-content-old/tests/browser_healthreport.js rename : browser/components/preferences/in-content/tests/browser_homepages_filter_aboutpreferences.js => browser/components/preferences/in-content-old/tests/browser_homepages_filter_aboutpreferences.js rename : browser/components/preferences/in-content/tests/browser_notifications_do_not_disturb.js => browser/components/preferences/in-content-old/tests/browser_notifications_do_not_disturb.js rename : browser/components/preferences/in-content/tests/browser_permissions_urlFieldHidden.js => browser/components/preferences/in-content-old/tests/browser_permissions_urlFieldHidden.js rename : browser/components/preferences/in-content/tests/browser_privacypane_1.js => browser/components/preferences/in-content-old/tests/browser_privacypane_1.js rename : browser/components/preferences/in-content/tests/browser_privacypane_3.js => browser/components/preferences/in-content-old/tests/browser_privacypane_3.js rename : browser/components/preferences/in-content/tests/browser_privacypane_4.js => browser/components/preferences/in-content-old/tests/browser_privacypane_4.js rename : browser/components/preferences/in-content/tests/browser_privacypane_5.js => browser/components/preferences/in-content-old/tests/browser_privacypane_5.js rename : browser/components/preferences/in-content/tests/browser_privacypane_8.js => browser/components/preferences/in-content-old/tests/browser_privacypane_8.js rename : browser/components/preferences/in-content/tests/browser_proxy_backup.js => browser/components/preferences/in-content-old/tests/browser_proxy_backup.js rename : browser/components/preferences/in-content/tests/browser_sanitizeOnShutdown_prefLocked.js => browser/components/preferences/in-content-old/tests/browser_sanitizeOnShutdown_prefLocked.js rename : browser/components/preferences/in-content/tests/browser_searchsuggestions.js => browser/components/preferences/in-content-old/tests/browser_searchsuggestions.js rename : browser/components/preferences/in-content/tests/browser_security.js => browser/components/preferences/in-content-old/tests/browser_security.js rename : browser/components/preferences/in-content/tests/browser_subdialogs.js => browser/components/preferences/in-content-old/tests/browser_subdialogs.js rename : browser/components/preferences/in-content/tests/browser_telemetry.js => browser/components/preferences/in-content-old/tests/browser_telemetry.js rename : browser/components/preferences/in-content/tests/head.js => browser/components/preferences/in-content-old/tests/head.js rename : browser/components/preferences/in-content/tests/privacypane_tests_perwindow.js => browser/components/preferences/in-content-old/tests/privacypane_tests_perwindow.js rename : browser/components/preferences/in-content/tests/site_data_test.html => browser/components/preferences/in-content-old/tests/site_data_test.html rename : browser/components/preferences/in-content/tests/subdialog.xul => browser/components/preferences/in-content-old/tests/subdialog.xul rename : browser/components/preferences/in-content/tests/subdialog2.xul => browser/components/preferences/in-content-old/tests/subdialog2.xul rename : browser/locales/en-US/chrome/browser/preferences/advanced.dtd => browser/locales/en-US/chrome/browser/preferences-old/advanced.dtd rename : browser/locales/en-US/chrome/browser/preferences/applications.dtd => browser/locales/en-US/chrome/browser/preferences-old/applications.dtd rename : browser/locales/en-US/chrome/browser/preferences/containers.dtd => browser/locales/en-US/chrome/browser/preferences-old/containers.dtd rename : browser/locales/en-US/chrome/browser/preferences/containers.properties => browser/locales/en-US/chrome/browser/preferences-old/containers.properties rename : browser/locales/en-US/chrome/browser/preferences/content.dtd => browser/locales/en-US/chrome/browser/preferences-old/content.dtd rename : browser/locales/en-US/chrome/browser/preferences/main.dtd => browser/locales/en-US/chrome/browser/preferences-old/main.dtd rename : browser/locales/en-US/chrome/browser/preferences/preferences.dtd => browser/locales/en-US/chrome/browser/preferences-old/preferences.dtd rename : browser/locales/en-US/chrome/browser/preferences/preferences.properties => browser/locales/en-US/chrome/browser/preferences-old/preferences.properties rename : browser/locales/en-US/chrome/browser/preferences/privacy.dtd => browser/locales/en-US/chrome/browser/preferences-old/privacy.dtd rename : browser/locales/en-US/chrome/browser/preferences/search.dtd => browser/locales/en-US/chrome/browser/preferences-old/search.dtd rename : browser/locales/en-US/chrome/browser/preferences/security.dtd => browser/locales/en-US/chrome/browser/preferences-old/security.dtd rename : browser/locales/en-US/chrome/browser/preferences/sync.dtd => browser/locales/en-US/chrome/browser/preferences-old/sync.dtd rename : browser/locales/en-US/chrome/browser/preferences/tabs.dtd => browser/locales/en-US/chrome/browser/preferences-old/tabs.dtd extra : rebase_source : a2e39a4526b4938d3275978ab54bd24ed8427d1a
		
			
				
	
	
		
			351 lines
		
	
	
	
		
			15 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			351 lines
		
	
	
	
		
			15 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /* Any copyright is dedicated to the Public Domain.
 | |
|  * http://creativecommons.org/publicdomain/zero/1.0/ */
 | |
| 
 | |
| requestLongerTimeout(2);
 | |
| 
 | |
| function test() {
 | |
|   waitForExplicitFinish();
 | |
|   requestLongerTimeout(3);
 | |
|   testRunner.runTests();
 | |
| }
 | |
| 
 | |
| var testRunner = {
 | |
| 
 | |
|   tests:
 | |
|     [
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "test.com";
 | |
|           params.btnAllow.doCommand();
 | |
|           is(params.tree.view.rowCount, 1, "added exception shows up in treeview");
 | |
|           is(params.tree.view.getCellText(0, params.nameCol), "http://test.com",
 | |
|                                           "origin name should be set correctly");
 | |
|           is(params.tree.view.getCellText(0, params.statusCol), params.allowText,
 | |
|                                           "permission text should be set correctly");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "http://test.com", data: "added",
 | |
|                         capability: Ci.nsIPermissionManager.ALLOW_ACTION }],
 | |
|       },
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "test.com";
 | |
|           params.btnBlock.doCommand();
 | |
|           is(params.tree.view.getCellText(0, params.nameCol), "http://test.com",
 | |
|                                           "origin name should be set correctly");
 | |
|           is(params.tree.view.getCellText(0, params.statusCol), params.denyText,
 | |
|                                           "permission should change to deny in UI");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "http://test.com", data: "changed",
 | |
|                         capability: Ci.nsIPermissionManager.DENY_ACTION  }],
 | |
|       },
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "test.com";
 | |
|           params.btnAllow.doCommand();
 | |
|           is(params.tree.view.getCellText(0, params.nameCol), "http://test.com",
 | |
|                                           "origin name should be set correctly");
 | |
|           is(params.tree.view.getCellText(0, params.statusCol), params.allowText,
 | |
|                                           "permission should revert back to allow");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "http://test.com", data: "changed",
 | |
|                         capability: Ci.nsIPermissionManager.ALLOW_ACTION }],
 | |
|       },
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "test.com";
 | |
|           params.btnRemove.doCommand();
 | |
|           is(params.tree.view.rowCount, 0, "exception should be removed");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "http://test.com", data: "deleted" }],
 | |
|       },
 | |
|       {
 | |
|         expectPermObservancesDuringTestFunction: true,
 | |
|         test(params) {
 | |
|           let uri = params.ioService.newURI("http://test.com");
 | |
|           params.pm.add(uri, "popup", Ci.nsIPermissionManager.DENY_ACTION);
 | |
|           is(params.tree.view.rowCount, 0, "adding unrelated permission should not change display");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "popup", origin: "http://test.com", data: "added",
 | |
|                         capability: Ci.nsIPermissionManager.DENY_ACTION }],
 | |
|         cleanUp(params) {
 | |
|           let uri = params.ioService.newURI("http://test.com");
 | |
|           params.pm.remove(uri, "popup");
 | |
|         },
 | |
|       },
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "https://test.com:12345";
 | |
|           params.btnAllow.doCommand();
 | |
|           is(params.tree.view.rowCount, 1, "added exception shows up in treeview");
 | |
|           is(params.tree.view.getCellText(0, params.nameCol), "https://test.com:12345",
 | |
|                                           "origin name should be set correctly");
 | |
|           is(params.tree.view.getCellText(0, params.statusCol), params.allowText,
 | |
|                                           "permission text should be set correctly");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "https://test.com:12345", data: "added",
 | |
|                         capability: Ci.nsIPermissionManager.ALLOW_ACTION }],
 | |
|       },
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "https://test.com:12345";
 | |
|           params.btnBlock.doCommand();
 | |
|           is(params.tree.view.getCellText(0, params.nameCol), "https://test.com:12345",
 | |
|                                           "origin name should be set correctly");
 | |
|           is(params.tree.view.getCellText(0, params.statusCol), params.denyText,
 | |
|                                           "permission should change to deny in UI");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "https://test.com:12345", data: "changed",
 | |
|                         capability: Ci.nsIPermissionManager.DENY_ACTION  }],
 | |
|       },
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "https://test.com:12345";
 | |
|           params.btnAllow.doCommand();
 | |
|           is(params.tree.view.getCellText(0, params.nameCol), "https://test.com:12345",
 | |
|                                           "origin name should be set correctly");
 | |
|           is(params.tree.view.getCellText(0, params.statusCol), params.allowText,
 | |
|                                           "permission should revert back to allow");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "https://test.com:12345", data: "changed",
 | |
|                         capability: Ci.nsIPermissionManager.ALLOW_ACTION }],
 | |
|       },
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "https://test.com:12345";
 | |
|           params.btnRemove.doCommand();
 | |
|           is(params.tree.view.rowCount, 0, "exception should be removed");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "https://test.com:12345", data: "deleted" }],
 | |
|       },
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "localhost:12345";
 | |
|           params.btnAllow.doCommand();
 | |
|           is(params.tree.view.rowCount, 1, "added exception shows up in treeview");
 | |
|           is(params.tree.view.getCellText(0, params.nameCol), "http://localhost:12345",
 | |
|                                           "origin name should be set correctly");
 | |
|           is(params.tree.view.getCellText(0, params.statusCol), params.allowText,
 | |
|                                           "permission text should be set correctly");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "http://localhost:12345", data: "added",
 | |
|                         capability: Ci.nsIPermissionManager.ALLOW_ACTION }],
 | |
|       },
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "localhost:12345";
 | |
|           params.btnBlock.doCommand();
 | |
|           is(params.tree.view.getCellText(0, params.nameCol), "http://localhost:12345",
 | |
|                                           "origin name should be set correctly");
 | |
|           is(params.tree.view.getCellText(0, params.statusCol), params.denyText,
 | |
|                                           "permission should change to deny in UI");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "http://localhost:12345", data: "changed",
 | |
|                         capability: Ci.nsIPermissionManager.DENY_ACTION  }],
 | |
|       },
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "localhost:12345";
 | |
|           params.btnAllow.doCommand();
 | |
|           is(params.tree.view.getCellText(0, params.nameCol), "http://localhost:12345",
 | |
|                                           "origin name should be set correctly");
 | |
|           is(params.tree.view.getCellText(0, params.statusCol), params.allowText,
 | |
|                                           "permission should revert back to allow");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "http://localhost:12345", data: "changed",
 | |
|                         capability: Ci.nsIPermissionManager.ALLOW_ACTION }],
 | |
|       },
 | |
|       {
 | |
|         test(params) {
 | |
|           params.url.value = "localhost:12345";
 | |
|           params.btnRemove.doCommand();
 | |
|           is(params.tree.view.rowCount, 0, "exception should be removed");
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "http://localhost:12345", data: "deleted" }],
 | |
|       },
 | |
|       {
 | |
|         expectPermObservancesDuringTestFunction: true,
 | |
|         test(params) {
 | |
|           for (let URL of ["http://a", "http://z", "http://b"]) {
 | |
|             let URI = params.ioService.newURI(URL);
 | |
|             params.pm.add(URI, "cookie", Ci.nsIPermissionManager.ALLOW_ACTION);
 | |
|           }
 | |
| 
 | |
|           is(params.tree.view.rowCount, 3, "Three permissions should be present");
 | |
|           is(params.tree.view.getCellText(0, params.nameCol), "http://a",
 | |
|              "site should be sorted. 'a' should be first");
 | |
|           is(params.tree.view.getCellText(1, params.nameCol), "http://b",
 | |
|              "site should be sorted. 'b' should be second");
 | |
|           is(params.tree.view.getCellText(2, params.nameCol), "http://z",
 | |
|              "site should be sorted. 'z' should be third");
 | |
| 
 | |
|           // Sort descending then check results in cleanup since sorting isn't synchronous.
 | |
|           EventUtils.synthesizeMouseAtCenter(params.doc.getElementById("siteCol"), {},
 | |
|                                              params.doc.defaultView);
 | |
|           params.btnApplyChanges.doCommand();
 | |
|         },
 | |
|         observances: [{ type: "cookie", origin: "http://a", data: "added",
 | |
|                         capability: Ci.nsIPermissionManager.ALLOW_ACTION },
 | |
|                       { type: "cookie", origin: "http://z", data: "added",
 | |
|                         capability: Ci.nsIPermissionManager.ALLOW_ACTION },
 | |
|                       { type: "cookie", origin: "http://b", data: "added",
 | |
|                         capability: Ci.nsIPermissionManager.ALLOW_ACTION }],
 | |
|         cleanUp(params) {
 | |
|           is(params.tree.view.getCellText(0, params.nameCol), "http://z",
 | |
|              "site should be sorted. 'z' should be first");
 | |
|           is(params.tree.view.getCellText(1, params.nameCol), "http://b",
 | |
|              "site should be sorted. 'b' should be second");
 | |
|           is(params.tree.view.getCellText(2, params.nameCol), "http://a",
 | |
|              "site should be sorted. 'a' should be third");
 | |
| 
 | |
|           for (let URL of ["http://a", "http://z", "http://b"]) {
 | |
|             let uri = params.ioService.newURI(URL);
 | |
|             params.pm.remove(uri, "cookie");
 | |
|           }
 | |
|         },
 | |
|       },
 | |
|     ],
 | |
| 
 | |
|   _currentTest: -1,
 | |
| 
 | |
|   runTests() {
 | |
|     this._currentTest++;
 | |
| 
 | |
|     info("Running test #" + (this._currentTest + 1) + "\n");
 | |
|     let that = this;
 | |
|     let p = this.runCurrentTest(this._currentTest + 1);
 | |
|     p.then(function() {
 | |
|       if (that._currentTest == that.tests.length - 1) {
 | |
|         finish();
 | |
|       } else {
 | |
|         that.runTests();
 | |
|       }
 | |
|     });
 | |
|   },
 | |
| 
 | |
|   runCurrentTest(testNumber) {
 | |
|     return new Promise(function(resolve, reject) {
 | |
| 
 | |
|       let helperFunctions = {
 | |
|         windowLoad(win) {
 | |
|           let doc = win.document;
 | |
|           let params = {
 | |
|             doc,
 | |
|             tree: doc.getElementById("permissionsTree"),
 | |
|             nameCol: doc.getElementById("permissionsTree").treeBoxObject.columns.getColumnAt(0),
 | |
|             statusCol: doc.getElementById("permissionsTree").treeBoxObject.columns.getColumnAt(1),
 | |
|             url: doc.getElementById("url"),
 | |
|             btnAllow: doc.getElementById("btnAllow"),
 | |
|             btnBlock: doc.getElementById("btnBlock"),
 | |
|             btnApplyChanges: doc.getElementById("btnApplyChanges"),
 | |
|             btnRemove: doc.getElementById("removePermission"),
 | |
|             pm: Cc["@mozilla.org/permissionmanager;1"]
 | |
|                        .getService(Ci.nsIPermissionManager),
 | |
|             ioService: Cc["@mozilla.org/network/io-service;1"]
 | |
|                               .getService(Ci.nsIIOService),
 | |
|             allowText: win.gPermissionManager._getCapabilityString(
 | |
|                                 Ci.nsIPermissionManager.ALLOW_ACTION),
 | |
|             denyText: win.gPermissionManager._getCapabilityString(
 | |
|                                Ci.nsIPermissionManager.DENY_ACTION),
 | |
|             allow: Ci.nsIPermissionManager.ALLOW_ACTION,
 | |
|             deny: Ci.nsIPermissionManager.DENY_ACTION,
 | |
|           };
 | |
| 
 | |
|           let permObserver = {
 | |
|             observe(aSubject, aTopic, aData) {
 | |
|               if (aTopic != "perm-changed")
 | |
|                 return;
 | |
| 
 | |
|               if (testRunner.tests[testRunner._currentTest].observances.length == 0) {
 | |
|                 // Should fail here as we are not expecting a notification, but we don't.
 | |
|                 // See bug 1063410.
 | |
|                 return;
 | |
|               }
 | |
| 
 | |
|               let permission = aSubject.QueryInterface(Ci.nsIPermission);
 | |
|               let expected = testRunner.tests[testRunner._currentTest].observances.shift();
 | |
| 
 | |
|               is(aData, expected.data, "type of message should be the same");
 | |
|               for (let prop of ["type", "capability"]) {
 | |
|                 if (expected[prop])
 | |
|                   is(permission[prop], expected[prop],
 | |
|                     "property: \"" + prop + "\" should be equal");
 | |
|               }
 | |
| 
 | |
|               if (expected.origin) {
 | |
|                 is(permission.principal.origin, expected.origin,
 | |
|                    "property: \"origin\" should be equal");
 | |
|               }
 | |
| 
 | |
|               os.removeObserver(permObserver, "perm-changed");
 | |
| 
 | |
|               let testCase = testRunner.tests[testRunner._currentTest];
 | |
|               if (!testCase.expectPermObservancesDuringTestFunction) {
 | |
|                 if (testCase.cleanUp) {
 | |
|                   testCase.cleanUp(params);
 | |
|                 }
 | |
| 
 | |
|                 gBrowser.removeCurrentTab();
 | |
|                 resolve();
 | |
|               }
 | |
|             },
 | |
|           };
 | |
| 
 | |
|           let os = Cc["@mozilla.org/observer-service;1"]
 | |
|                      .getService(Ci.nsIObserverService);
 | |
| 
 | |
|           os.addObserver(permObserver, "perm-changed", false);
 | |
| 
 | |
|           if (testRunner._currentTest == 0) {
 | |
|             is(params.tree.view.rowCount, 0, "no cookie exceptions");
 | |
|           }
 | |
| 
 | |
|           try {
 | |
|             let testCase = testRunner.tests[testRunner._currentTest];
 | |
|             testCase.test(params);
 | |
|             if (testCase.expectPermObservancesDuringTestFunction) {
 | |
|               if (testCase.cleanUp) {
 | |
|                 testCase.cleanUp(params);
 | |
|               }
 | |
| 
 | |
|               gBrowser.removeCurrentTab();
 | |
|               resolve();
 | |
|             }
 | |
|           } catch (ex) {
 | |
|             ok(false, "exception while running test #" +
 | |
|                       testNumber + ": " + ex);
 | |
|           }
 | |
|         },
 | |
|       };
 | |
| 
 | |
|       registerCleanupFunction(function() {
 | |
|         Services.prefs.clearUserPref("privacy.history.custom");
 | |
|       });
 | |
| 
 | |
|       openPreferencesViaOpenPreferencesAPI("panePrivacy", null, {leaveOpen: true}).then(function() {
 | |
|         let doc = gBrowser.contentDocument;
 | |
|         let historyMode = doc.getElementById("historyMode");
 | |
|         historyMode.value = "custom";
 | |
|         historyMode.doCommand();
 | |
|         doc.getElementById("cookieExceptions").doCommand();
 | |
| 
 | |
|         let subDialogURL = "chrome://browser/content/preferences/permissions.xul";
 | |
|         promiseLoadSubDialog(subDialogURL).then(function(win) {
 | |
|           helperFunctions.windowLoad(win);
 | |
|         });
 | |
|       });
 | |
|     });
 | |
|   },
 | |
| };
 |