Bug 925847 - WorkerNavigator does not implement all of NavigatorID. r=nsm

This commit is contained in:
Tareq Khandaker 2013-11-20 09:29:01 -05:00
parent d5481a6e40
commit e5caa83fa5
6 changed files with 34 additions and 38 deletions

View File

@ -142,23 +142,6 @@ public:
// Helper to initialize mMessagesManager.
nsresult EnsureMessagesManager();
// WebIDL API
void GetAppName(nsString& aAppName)
{
NS_GetNavigatorAppName(aAppName);
}
void GetAppVersion(nsString& aAppVersion, ErrorResult& aRv)
{
aRv = GetAppVersion(aAppVersion);
}
void GetPlatform(nsString& aPlatform, ErrorResult& aRv)
{
aRv = GetPlatform(aPlatform);
}
void GetUserAgent(nsString& aUserAgent, ErrorResult& aRv)
{
aRv = GetUserAgent(aUserAgent);
}
// The XPCOM GetProduct is OK
// The XPCOM GetLanguage is OK
bool OnLine();

View File

@ -32,18 +32,22 @@ Navigator implements NavigatorStorageUtils;
[NoInterfaceObject]
interface NavigatorID {
// WebKit/Blink/Trident/Presto support this (hardcoded "Mozilla").
[Constant]
readonly attribute DOMString appCodeName; // constant "Mozilla"
[Constant]
readonly attribute DOMString appName;
[Throws]
[Constant]
readonly attribute DOMString appVersion;
[Throws]
[Constant]
readonly attribute DOMString platform;
[Throws]
[Constant]
readonly attribute DOMString userAgent;
[Constant]
readonly attribute DOMString product; // constant "Gecko"
// Spec has this as a const, but that's wrong because it should not
// be on the interface object.
//const DOMString product = "Gecko"; // for historical reasons
readonly attribute DOMString product;
// Everyone but WebKit/Blink supports this. See bug 679971.
boolean taintEnabled(); // constant false
};
[NoInterfaceObject]
@ -136,9 +140,6 @@ callback interface MozIdleObserver {
// nsIDOMNavigator
partial interface Navigator {
// WebKit/Blink/Trident/Presto support this (hardcoded "Mozilla").
[Throws]
readonly attribute DOMString appCodeName;
[Throws]
readonly attribute DOMString oscpu;
// WebKit/Blink support this; Trident/Presto do not.
@ -157,8 +158,6 @@ partial interface Navigator {
// WebKit/Blink/Trident/Presto support this.
[Throws]
boolean javaEnabled();
// Everyone but WebKit/Blink supports this. See bug 679971.
boolean taintEnabled();
/**
* Navigator requests to add an idle observer to the existing window.

View File

@ -3,12 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
interface WorkerNavigator {
[Constant]
readonly attribute DOMString appName;
[Constant]
readonly attribute DOMString appVersion;
[Constant]
readonly attribute DOMString platform;
[Constant]
readonly attribute DOMString userAgent;
};
WorkerNavigator implements NavigatorID;

View File

@ -52,6 +52,10 @@ public:
MOZ_COUNT_DTOR(WorkerNavigator);
}
void GetAppCodeName(nsString& aAppCodeName) const
{
aAppCodeName.AssignLiteral("Mozilla");
}
void GetAppName(nsString& aAppName) const
{
aAppName = mAppName;
@ -64,6 +68,14 @@ public:
{
aPlatform = mPlatform;
}
void GetProduct(nsString& aProduct) const
{
aProduct.AssignLiteral("Gecko");
}
bool TaintEnabled() const
{
return false;
}
void GetUserAgent(nsString& aUserAgent) const
{
aUserAgent = mUserAgent;

View File

@ -3,9 +3,12 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var supportedProps = [
"appCodeName",
"appName",
"appVersion",
"platform",
"product",
"taintEnabled",
"userAgent"
];
@ -27,7 +30,7 @@ for (var index = 0; index < supportedProps.length; index++) {
obj = {
name: prop,
value: navigator[prop]
value: prop === "taintEnabled" ? navigator[prop]() : navigator[prop]
};
postMessage(JSON.stringify(obj));

View File

@ -35,6 +35,11 @@ Tests of DOM Worker Navigator
return;
}
if (args.name === "taintEnabled") {
is(navigator[args.name](), args.value, args.name + "() returns false.");
return;
}
is(navigator[args.name], args.value,
"Mismatched navigator string for " + args.name + "!");
};