mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 859601 - mozContacts API - return undefined if the API is unsupported on the platform, not null. r=bent
This commit is contained in:
parent
d2afb6f364
commit
6331890d3c
@ -351,6 +351,8 @@
|
||||
@BINPATH@/components/BrowserElementParent.js
|
||||
@BINPATH@/components/ContactManager.js
|
||||
@BINPATH@/components/ContactManager.manifest
|
||||
@BINPATH@/components/NavigatorPropertyHelper.js
|
||||
@BINPATH@/components/NavigatorPropertyHelper.manifest
|
||||
@BINPATH@/components/PermissionSettings.js
|
||||
@BINPATH@/components/PermissionSettings.manifest
|
||||
@BINPATH@/components/PermissionPromptService.js
|
||||
|
@ -514,6 +514,8 @@
|
||||
@BINPATH@/components/PermissionSettings.manifest
|
||||
@BINPATH@/components/ContactManager.js
|
||||
@BINPATH@/components/ContactManager.manifest
|
||||
@BINPATH@/components/NavigatorPropteryHelper.js
|
||||
@BINPATH@/components/NavigatorPropertyHelper.manifest
|
||||
@BINPATH@/components/AlarmsManager.js
|
||||
@BINPATH@/components/AlarmsManager.manifest
|
||||
@BINPATH@/components/TCPSocket.js
|
||||
|
@ -21,6 +21,8 @@ EXTRA_COMPONENTS = \
|
||||
SiteSpecificUserAgent.manifest \
|
||||
ConsoleAPI.js \
|
||||
ConsoleAPI.manifest \
|
||||
NavigatorPropertyHelper.js \
|
||||
NavigatorPropertyHelper.manifest \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_JS_MODULES = ConsoleAPIStorage.jsm \
|
||||
|
66
dom/base/NavigatorPropertyHelper.js
Normal file
66
dom/base/NavigatorPropertyHelper.js
Normal file
@ -0,0 +1,66 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const DEBUG = false;
|
||||
function debug(s) { dump("-*- NavigatorPropertyHelper: " + s + "\n"); }
|
||||
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function NavigatorPropertyHelper() { };
|
||||
|
||||
NavigatorPropertyHelper.prototype = {
|
||||
|
||||
classID : Components.ID("{f0d03420-a0ce-11e2-9e96-0800200c9a66}"),
|
||||
QueryInterface : XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
|
||||
observe: function observe(subject, topic, data) {
|
||||
if (DEBUG) debug("topic: " + topic + ", data: " + data);
|
||||
let cm = Components.classes["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
|
||||
switch (topic) {
|
||||
case 'app-startup':
|
||||
let enumerator = cm.enumerateCategory("JavaScript-navigator-property-maybe");
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let entry = enumerator.getNext().QueryInterface(Ci.nsISupportsCString);
|
||||
let keyVal = cm.getCategoryEntry("JavaScript-navigator-property-maybe", entry).split(',');
|
||||
try {
|
||||
if (Services.prefs.getBoolPref(entry)) {
|
||||
if (DEBUG) debug("enable: " + keyVal[0]);
|
||||
cm.addCategoryEntry("JavaScript-navigator-property", keyVal[0], keyVal[1], false, false);
|
||||
}
|
||||
} catch (ex) {
|
||||
if (DEBUG) debug("no pref found: " + entry);
|
||||
}
|
||||
Services.prefs.addObserver(entry, this, true);
|
||||
}
|
||||
break;
|
||||
case 'nsPref:changed':
|
||||
let keyVal = cm.getCategoryEntry("JavaScript-navigator-property-maybe", data).split(',');
|
||||
let key = keyVal[0];
|
||||
let val = keyVal[1];
|
||||
try {
|
||||
if (Services.prefs.getBoolPref(data)) {
|
||||
if (DEBUG) debug("enable: " + key);
|
||||
cm.addCategoryEntry("JavaScript-navigator-property", key, val, false, false);
|
||||
} else {
|
||||
if (DEBUG) debug("disable: " + key);
|
||||
cm.deleteCategoryEntry("JavaScript-navigator-property", key, false);
|
||||
}
|
||||
} catch (ex) {
|
||||
if (DEBUG) debug("no pref found: " + data);
|
||||
cm.deleteCategoryEntry("JavaScript-navigator-property", key, false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (DEBUG) debug("unknown topic: " + topic);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NavigatorPropertyHelper])
|
3
dom/base/NavigatorPropertyHelper.manifest
Normal file
3
dom/base/NavigatorPropertyHelper.manifest
Normal file
@ -0,0 +1,3 @@
|
||||
component {f0d03420-a0ce-11e2-9e96-0800200c9a66} NavigatorPropertyHelper.js
|
||||
contract @mozilla.org/navigatorPropertyHelper;1 {f0d03420-a0ce-11e2-9e96-0800200c9a66}
|
||||
category app-startup NavigatorPropertyHelper service,@mozilla.org/navigatorPropertyHelper;1
|
@ -700,10 +700,6 @@ ContactManager.prototype = {
|
||||
},
|
||||
|
||||
init: function(aWindow) {
|
||||
// Set navigator.mozContacts to null.
|
||||
if (!Services.prefs.getBoolPref("dom.mozContacts.enabled"))
|
||||
return null;
|
||||
|
||||
this.initHelper(aWindow, ["Contacts:Find:Return:OK", "Contacts:Find:Return:KO",
|
||||
"Contacts:Clear:Return:OK", "Contacts:Clear:Return:KO",
|
||||
"Contact:Save:Return:OK", "Contact:Save:Return:KO",
|
||||
|
@ -22,4 +22,4 @@ category JavaScript-global-constructor mozContact @mozilla.org/contact;1
|
||||
|
||||
component {1d70322b-f11b-4f19-9586-7bf291f212aa} ContactManager.js
|
||||
contract @mozilla.org/contactManager;1 {1d70322b-f11b-4f19-9586-7bf291f212aa}
|
||||
category JavaScript-navigator-property mozContacts @mozilla.org/contactManager;1
|
||||
category JavaScript-navigator-property-maybe dom.mozContacts.enabled mozContacts,@mozilla.org/contactManager;1
|
||||
|
@ -228,11 +228,13 @@ function checkContacts(contact1, contact2) {
|
||||
}
|
||||
}
|
||||
|
||||
function tests() {
|
||||
|
||||
var req;
|
||||
var index = 0;
|
||||
|
||||
var mozContacts = window.navigator.mozContacts;
|
||||
|
||||
ok(mozContacts, "mozContacts exists");
|
||||
var steps = [
|
||||
function () {
|
||||
ok(true, "Deleting database");
|
||||
@ -1245,11 +1247,12 @@ function permissionTest() {
|
||||
}
|
||||
}
|
||||
|
||||
var gContactsEnabled = SpecialPowers.getBoolPref("dom.mozContacts.enabled");
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(permissionTest);
|
||||
permissionTest();
|
||||
};
|
||||
|
||||
ok(true, "test passed");
|
||||
var gContactsEnabled = SpecialPowers.getBoolPref("dom.mozContacts.enabled");
|
||||
addLoadEvent(tests);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -261,6 +261,8 @@
|
||||
@BINPATH@/components/ConsoleAPI.js
|
||||
@BINPATH@/components/ContactManager.js
|
||||
@BINPATH@/components/ContactManager.manifest
|
||||
@BINPATH@/components/NavigatorPropteryHelper.js
|
||||
@BINPATH@/components/NavigatorPropertyHelper.manifest
|
||||
@BINPATH@/components/SettingsManager.js
|
||||
@BINPATH@/components/SettingsManager.manifest
|
||||
@BINPATH@/components/SettingsService.js
|
||||
|
Loading…
Reference in New Issue
Block a user