WorkerNavigator is missing some attributes
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jun 2016 17:44:20 +0000 (17:44 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jun 2016 17:44:20 +0000 (17:44 +0000)
commitdfea4c1d0e8402b2a462596c4b9a2062cd9687c1
treef9ec143bf1ed1a935b3f892ee0fd05b988be84e5
parent23d0b2d9aba40ef32e37f0c020c4a74503382713
WorkerNavigator is missing some attributes
https://bugs.webkit.org/show_bug.cgi?id=158593
<rdar://problem/26731334>

Reviewed by Darin Adler.

Source/WebCore:

Add attributes that are missing on WorkerNavigator:
- appCodeName
- hardwareConcurrency
- language
- product
- productSub
- vendor
- vendorSub

Firefox and Chrome already expose those attributes.

Relevant specification:
https://html.spec.whatwg.org/multipage/workers.html#the-workernavigator-object

This patch also refactors the IDL to match the specification more
closely and promote sharing between Navigator and WorkerNavigator.

No new tests, updated existing test.

* CMakeLists.txt:
* DerivedSources.make:
Add new supplemental IDL files.

* page/Navigator.cpp:
* page/Navigator.h:
Moved language() / hardwareConcurrency() from Navigator to NavigatorBase
so that it can be used by NavigatorWorker as well.

* page/NavigatorBase.h:
* page/NavigatorBase.cpp:
(WebCore::NavigatorBase::language):
The implementation still calls defaultLanguage() but I updated it to be
thread safe on all platforms.

(WebCore::NavigatorBase::hardwareConcurrency):
Use std::call_once() for thread safety.

* page/Navigator.idl:
* page/NavigatorConcurrentHardware.idl: Copied from Source/WebCore/page/WorkerNavigator.idl.
* page/NavigatorID.idl: Copied from Source/WebCore/page/WorkerNavigator.idl.
* page/NavigatorLanguage.idl: Copied from Source/WebCore/page/WorkerNavigator.idl.
* page/NavigatorOnLine.idl: Copied from Source/WebCore/page/WorkerNavigator.idl.
* page/WorkerNavigator.idl:
Move several attributes to their own supplemental interfaces to match
the specification and promote sharing with WorkerNavigator.

* platform/Language.cpp:
(WebCore::userPreferredLanguages):
* platform/Language.h:
Made thread-safe on all platforms.

Source/WTF:

* wtf/PlatformUserPreferredLanguages.h:
* wtf/PlatformUserPreferredLanguagesWin.cpp:
(WTF::platformLanguage):
(WTF::platformUserPreferredLanguages):

Make platformUserPreferredLanguages() thread safe on Windows. The
Mac and Unix implementations are already thread-safe.

LayoutTests:

Improved test coverage for WorkerNavigator.

* fast/workers/resources/worker-navigator.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201970 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/workers/resources/worker-navigator.js
LayoutTests/fast/workers/worker-navigator-expected.txt
Source/WTF/ChangeLog
Source/WTF/wtf/PlatformUserPreferredLanguages.h
Source/WTF/wtf/PlatformUserPreferredLanguagesWin.cpp
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/page/Navigator.cpp
Source/WebCore/page/Navigator.h
Source/WebCore/page/Navigator.idl
Source/WebCore/page/NavigatorBase.cpp
Source/WebCore/page/NavigatorBase.h
Source/WebCore/page/NavigatorConcurrentHardware.idl [new file with mode: 0644]
Source/WebCore/page/NavigatorID.idl [new file with mode: 0644]
Source/WebCore/page/NavigatorLanguage.idl [new file with mode: 0644]
Source/WebCore/page/NavigatorOnLine.idl [new file with mode: 0644]
Source/WebCore/page/WorkerNavigator.idl
Source/WebCore/platform/Language.cpp
Source/WebCore/platform/Language.h