-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a variety of missing properties to Navigator: - appCodeName, product, productSub, vendor, and vendorSub from NavigatorID - language and languages from NavigatorLanguage - onLine from NavigatorOnLine - javaEnabled() from NavigatorPlugins (fixes #1467) Also removes the nonstandard navigator.noUI property. We now emulate Chrome a bit more closely: we follow the spec with "navigator compatibility mode" of Chrome, which locks down appName, platform, and version to be more browser-like instead of Node.js-like. The default userAgent similarly gains a suffix "AppleWebKit/537.36 (KHTML, like Gecko)".
- Loading branch information
Showing
16 changed files
with
172 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use strict"; | ||
const idlUtils = require("../generated/utils"); | ||
const NavigatorIDImpl = require("./NavigatorID-impl").implementation; | ||
const NavigatorLanguageImpl = require("./NavigatorLanguage-impl").implementation; | ||
const NavigatorOnLineImpl = require("./NavigatorOnLine-impl").implementation; | ||
const NavigatorCookiesImpl = require("./NavigatorCookies-impl").implementation; | ||
const NavigatorPluginsImpl = require("./NavigatorPlugins-impl").implementation; | ||
const NavigatorConcurrentHardwareImpl = require("./NavigatorConcurrentHardware-impl").implementation; | ||
|
||
class NavigatorImpl { | ||
constructor(args, privateData) { | ||
this.userAgent = privateData.userAgent; | ||
this.languages = Object.freeze(["en-US", "en"]); | ||
} | ||
} | ||
|
||
idlUtils.mixin(NavigatorImpl.prototype, NavigatorIDImpl.prototype); | ||
idlUtils.mixin(NavigatorImpl.prototype, NavigatorLanguageImpl.prototype); | ||
idlUtils.mixin(NavigatorImpl.prototype, NavigatorOnLineImpl.prototype); | ||
idlUtils.mixin(NavigatorImpl.prototype, NavigatorCookiesImpl.prototype); | ||
idlUtils.mixin(NavigatorImpl.prototype, NavigatorPluginsImpl.prototype); | ||
idlUtils.mixin(NavigatorImpl.prototype, NavigatorConcurrentHardwareImpl.prototype); | ||
|
||
exports.implementation = NavigatorImpl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
interface Navigator { | ||
// objects implementing this interface also implement the interfaces given below | ||
}; | ||
Navigator implements NavigatorID; | ||
Navigator implements NavigatorLanguage; | ||
Navigator implements NavigatorOnLine; | ||
//Navigator implements NavigatorContentUtils; | ||
Navigator implements NavigatorCookies; | ||
Navigator implements NavigatorPlugins; | ||
Navigator implements NavigatorConcurrentHardware; | ||
|
||
[NoInterfaceObject, Exposed=(Window,Worker)] | ||
interface NavigatorID { | ||
[Exposed=Window] readonly attribute DOMString appCodeName; // constant "Mozilla" | ||
readonly attribute DOMString appName; // constant "Netscape" | ||
readonly attribute DOMString appVersion; | ||
readonly attribute DOMString platform; | ||
[Exposed=Window] readonly attribute DOMString product; // constant "Gecko" | ||
[Exposed=Window] readonly attribute DOMString productSub; | ||
readonly attribute DOMString userAgent; | ||
[Exposed=Window] readonly attribute DOMString vendor; | ||
[Exposed=Window] readonly attribute DOMString vendorSub; // constant "" | ||
|
||
// also has additional members in a partial interface | ||
}; | ||
|
||
[NoInterfaceObject, Exposed=(Window,Worker)] | ||
interface NavigatorLanguage { | ||
readonly attribute DOMString language; | ||
readonly attribute FrozenArray<DOMString> languages; | ||
}; | ||
|
||
[NoInterfaceObject, Exposed=(Window,Worker)] | ||
interface NavigatorOnLine { | ||
readonly attribute boolean onLine; | ||
}; | ||
|
||
[NoInterfaceObject] | ||
interface NavigatorCookies { | ||
readonly attribute boolean cookieEnabled; | ||
}; | ||
|
||
[NoInterfaceObject] | ||
interface NavigatorCookies { | ||
readonly attribute boolean cookieEnabled; | ||
}; | ||
|
||
[NoInterfaceObject] | ||
interface NavigatorPlugins { | ||
// [SameObject] readonly attribute PluginArray plugins; | ||
// [SameObject] readonly attribute MimeTypeArray mimeTypes; | ||
boolean javaEnabled(); | ||
}; | ||
|
||
[NoInterfaceObject, Exposed=(Window,Worker)] | ||
interface NavigatorConcurrentHardware { | ||
readonly attribute unsigned long long hardwareConcurrency; | ||
}; |
8 changes: 8 additions & 0 deletions
8
lib/jsdom/living/navigator/NavigatorConcurrentHardware-impl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use strict"; | ||
const os = require("os"); | ||
|
||
exports.implementation = class NavigatorConcurrentHardwareImpl { | ||
get hardwareConcurrency() { | ||
return os.cpus().length; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
|
||
exports.implementation = class NavigatorCookiesImpl { | ||
get cookieEnabled() { | ||
return true; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
|
||
exports.implementation = class NavigatorIDImpl { | ||
get appCodeName() { | ||
return "Mozilla"; | ||
} | ||
|
||
get appName() { | ||
return "Netscape"; | ||
} | ||
|
||
get appVersion() { | ||
return "4.0"; | ||
} | ||
|
||
get platform() { | ||
return ""; | ||
} | ||
|
||
get product() { | ||
return "Gecko"; | ||
} | ||
|
||
get productSub() { | ||
return "20030107"; | ||
} | ||
|
||
// see Navigator constructor for userAgent | ||
|
||
get vendor() { | ||
return "Google Inc."; | ||
} | ||
|
||
get vendorSub() { | ||
return ""; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
|
||
exports.implementation = class NavigatorLanguageImpl { | ||
get language() { | ||
return "en-US"; | ||
} | ||
|
||
// See Navigator constructor for languages | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
|
||
exports.implementation = class NavigatorOnLineImpl { | ||
get onLine() { | ||
return true; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
|
||
exports.implementation = class NavigatorPluginsImpl { | ||
javaEnabled() { | ||
return false; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters