Diff
Modified: trunk/LayoutTests/ChangeLog (201969 => 201970)
--- trunk/LayoutTests/ChangeLog 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/LayoutTests/ChangeLog 2016-06-11 17:44:20 UTC (rev 201970)
@@ -1,3 +1,15 @@
+2016-06-11 Chris Dumez <[email protected]>
+
+ WorkerNavigator is missing some attributes
+ https://bugs.webkit.org/show_bug.cgi?id=158593
+ <rdar://problem/26731334>
+
+ Reviewed by Darin Adler.
+
+ Improved test coverage for WorkerNavigator.
+
+ * fast/workers/resources/worker-navigator.js:
+
2016-06-10 Antti Koivisto <[email protected]>
Vary:Cookie validation doesn't work in private browsing
Modified: trunk/LayoutTests/fast/workers/resources/worker-navigator.js (201969 => 201970)
--- trunk/LayoutTests/fast/workers/resources/worker-navigator.js 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/LayoutTests/fast/workers/resources/worker-navigator.js 2016-06-11 17:44:20 UTC (rev 201970)
@@ -11,11 +11,28 @@
var worker = createWorker();
worker.postMessage("eval typeof navigator");
worker.postMessage("eval navigator");
-worker.postMessage("eval navigator.appName");
+
+// NavigatorConcurrentHardware
+worker.postMessage("eval navigator.hardwareConcurrency >= 1 && navigator.hardwareConcurrency <= 8");
+
+// NavigatorID
+worker.postMessage("eval navigator.appCodeName === 'Mozilla'");
+worker.postMessage("eval navigator.appName === 'Netscape'");
worker.postMessage("eval navigator.appVersion.indexOf('WebKit') != 0");
-worker.postMessage("eval typeof navigator.platform");
+worker.postMessage("eval typeof navigator.platform == 'string'");
+worker.postMessage("eval navigator.product === 'Gecko'");
+worker.postMessage("eval navigator.productSub === '20030107'");
worker.postMessage("eval navigator.userAgent.indexOf('WebKit') != 0");
-worker.postMessage("eval typeof navigator.onLine");
+worker.postMessage("eval navigator.vendor === 'Apple Computer, Inc.'");
+worker.postMessage("eval navigator.vendorSub === ''");
+
+// NavigatorLanguage
+worker.postMessage("eval typeof navigator.language == 'string'");
+
+// NavigatorOnLine
+worker.postMessage("eval typeof navigator._onLine_ == 'boolean'");
+
+
worker.postMessage("eval foo//bar");
worker._onmessage_ = function(evt) {
Modified: trunk/LayoutTests/fast/workers/worker-navigator-expected.txt (201969 => 201970)
--- trunk/LayoutTests/fast/workers/worker-navigator-expected.txt 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/LayoutTests/fast/workers/worker-navigator-expected.txt 2016-06-11 17:44:20 UTC (rev 201970)
@@ -2,10 +2,17 @@
typeof navigator: object
navigator: [object WorkerNavigator]
-navigator.appName: Netscape
+navigator.hardwareConcurrency >= 1 && navigator.hardwareConcurrency <= 8: true
+navigator.appCodeName === 'Mozilla': true
+navigator.appName === 'Netscape': true
navigator.appVersion.indexOf('WebKit') != 0: true
-typeof navigator.platform: string
+typeof navigator.platform == 'string': true
+navigator.product === 'Gecko': true
+navigator.productSub === '20030107': true
navigator.userAgent.indexOf('WebKit') != 0: true
-typeof navigator.onLine: boolean
+navigator.vendor === 'Apple Computer, Inc.': true
+navigator.vendorSub === '': true
+typeof navigator.language == 'string': true
+typeof navigator._onLine_ == 'boolean': true
DONE
Modified: trunk/Source/WTF/ChangeLog (201969 => 201970)
--- trunk/Source/WTF/ChangeLog 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WTF/ChangeLog 2016-06-11 17:44:20 UTC (rev 201970)
@@ -1,3 +1,19 @@
+2016-06-11 Chris Dumez <[email protected]>
+
+ WorkerNavigator is missing some attributes
+ https://bugs.webkit.org/show_bug.cgi?id=158593
+ <rdar://problem/26731334>
+
+ Reviewed by Darin Adler.
+
+ * 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.
+
2016-06-10 Alex Christensen <[email protected]>
Introduce WTF::UniqueRef
Modified: trunk/Source/WTF/wtf/PlatformUserPreferredLanguages.h (201969 => 201970)
--- trunk/Source/WTF/wtf/PlatformUserPreferredLanguages.h 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WTF/wtf/PlatformUserPreferredLanguages.h 2016-06-11 17:44:20 UTC (rev 201970)
@@ -33,6 +33,7 @@
WTF_EXPORT_PRIVATE void setPlatformUserPreferredLanguagesChangedCallback(void (*)());
+// This is thread-safe.
WTF_EXPORT_PRIVATE Vector<String> platformUserPreferredLanguages();
} // namespace WTF
Modified: trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesWin.cpp (201969 => 201970)
--- trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesWin.cpp 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesWin.cpp 2016-06-11 17:44:20 UTC (rev 201970)
@@ -26,12 +26,16 @@
#include "config.h"
#include "PlatformUserPreferredLanguages.h"
+#include <mutex>
#include <windows.h>
+#include <wtf/Lock.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WTF {
+static StaticLock platformLanguageMutex;
+
void setPlatformUserPreferredLanguagesChangedCallback(void (*)()) { }
static String localeInfo(LCTYPE localeType, const String& fallback)
@@ -54,9 +58,11 @@
static String platformLanguage()
{
+ std::lock_guard<StaticLock> lock(platformLanguageMutex);
+
static String computedDefaultLanguage;
if (!computedDefaultLanguage.isEmpty())
- return computedDefaultLanguage;
+ return computedDefaultLanguage.isolatedCopy();
String languageName = localeInfo(LOCALE_SISO639LANGNAME, "en");
String countryName = localeInfo(LOCALE_SISO3166CTRYNAME, String());
@@ -71,9 +77,7 @@
Vector<String> platformUserPreferredLanguages()
{
- Vector<String> userPreferredLanguages;
- userPreferredLanguages.append(platformLanguage());
- return userPreferredLanguages;
+ return { platformLanguage() };
}
} // namespace WTF
Modified: trunk/Source/WebCore/CMakeLists.txt (201969 => 201970)
--- trunk/Source/WebCore/CMakeLists.txt 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-06-11 17:44:20 UTC (rev 201970)
@@ -603,6 +603,10 @@
page/History.idl
page/Location.idl
page/Navigator.idl
+ page/NavigatorConcurrentHardware.idl
+ page/NavigatorID.idl
+ page/NavigatorLanguage.idl
+ page/NavigatorOnLine.idl
page/Performance.idl
page/PerformanceEntry.idl
page/PerformanceEntryList.idl
Modified: trunk/Source/WebCore/ChangeLog (201969 => 201970)
--- trunk/Source/WebCore/ChangeLog 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WebCore/ChangeLog 2016-06-11 17:44:20 UTC (rev 201970)
@@ -1,3 +1,62 @@
+2016-06-11 Chris Dumez <[email protected]>
+
+ WorkerNavigator is missing some attributes
+ https://bugs.webkit.org/show_bug.cgi?id=158593
+ <rdar://problem/26731334>
+
+ Reviewed by Darin Adler.
+
+ 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.
+
2016-06-11 Antti Koivisto <[email protected]>
Build fix.
Modified: trunk/Source/WebCore/DerivedSources.make (201969 => 201970)
--- trunk/Source/WebCore/DerivedSources.make 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WebCore/DerivedSources.make 2016-06-11 17:44:20 UTC (rev 201970)
@@ -514,6 +514,10 @@
$(WebCore)/page/History.idl \
$(WebCore)/page/Location.idl \
$(WebCore)/page/Navigator.idl \
+ $(WebCore)/page/NavigatorConcurrentHardware.idl \
+ $(WebCore)/page/NavigatorID.idl \
+ $(WebCore)/page/NavigatorLanguage.idl \
+ $(WebCore)/page/NavigatorOnLine.idl \
$(WebCore)/page/Performance.idl \
$(WebCore)/page/PerformanceEntry.idl \
$(WebCore)/page/PerformanceEntryList.idl \
Modified: trunk/Source/WebCore/page/Navigator.cpp (201969 => 201970)
--- trunk/Source/WebCore/page/Navigator.cpp 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WebCore/page/Navigator.cpp 2016-06-11 17:44:20 UTC (rev 201970)
@@ -38,7 +38,6 @@
#include "SecurityOrigin.h"
#include "Settings.h"
#include <wtf/HashSet.h>
-#include <wtf/NumberOfCores.h>
#include <wtf/StdLibExtras.h>
using namespace WTF;
@@ -78,11 +77,6 @@
return appVersion;
}
-String Navigator::language() const
-{
- return defaultLanguage();
-}
-
String Navigator::userAgent() const
{
if (!m_frame)
@@ -134,29 +128,7 @@
return true;
}
-#if defined(ENABLE_NAVIGATOR_HWCONCURRENCY)
-int Navigator::hardwareConcurrency() const
-{
- // Enforce a maximum for the number of cores reported to mitigate
- // fingerprinting for the minority of machines with large numbers of cores.
- // If machines with more than 8 cores become commonplace, we should bump this number.
- // see https://bugs.webkit.org/show_bug.cgi?id=132588 for the
- // rationale behind this decision.
#if PLATFORM(IOS)
- const int maxCoresToReport = 2;
-#else
- const int maxCoresToReport = 8;
-#endif
- int hardwareConcurrency = numberOfProcessorCores();
-
- if (hardwareConcurrency > maxCoresToReport)
- return maxCoresToReport;
-
- return hardwareConcurrency;
-}
-#endif
-
-#if PLATFORM(IOS)
bool Navigator::standalone() const
{
return m_frame && m_frame->settings().standalone();
Modified: trunk/Source/WebCore/page/Navigator.h (201969 => 201970)
--- trunk/Source/WebCore/page/Navigator.h 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WebCore/page/Navigator.h 2016-06-11 17:44:20 UTC (rev 201970)
@@ -45,14 +45,10 @@
virtual ~Navigator();
String appVersion() const;
- String language() const;
DOMPluginArray* plugins() const;
DOMMimeTypeArray* mimeTypes() const;
bool cookieEnabled() const;
bool javaEnabled() const;
-#if defined(ENABLE_NAVIGATOR_HWCONCURRENCY)
- int hardwareConcurrency() const;
-#endif
virtual String userAgent() const;
#if PLATFORM(IOS)
Modified: trunk/Source/WebCore/page/Navigator.idl (201969 => 201970)
--- trunk/Source/WebCore/page/Navigator.idl 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WebCore/page/Navigator.idl 2016-06-11 17:44:20 UTC (rev 201970)
@@ -20,27 +20,11 @@
[
GenerateIsReachable=ImplFrame,
] interface Navigator {
- [Nondeterministic] readonly attribute DOMString appCodeName;
- [Nondeterministic] readonly attribute DOMString appName;
- [Nondeterministic] readonly attribute DOMString appVersion;
- [Nondeterministic] readonly attribute DOMString language;
- [Nondeterministic] readonly attribute DOMString userAgent;
- [Nondeterministic] readonly attribute DOMString platform;
readonly attribute DOMPluginArray plugins;
readonly attribute DOMMimeTypeArray mimeTypes;
- [Nondeterministic] readonly attribute DOMString product;
- [Nondeterministic] readonly attribute DOMString productSub;
- [Nondeterministic] readonly attribute DOMString vendor;
- [Nondeterministic] readonly attribute DOMString vendorSub;
[Nondeterministic] readonly attribute boolean cookieEnabled;
[Nondeterministic] boolean javaEnabled();
- readonly attribute boolean onLine;
-
-#if defined(ENABLE_NAVIGATOR_HWCONCURRENCY)
- readonly attribute long hardwareConcurrency;
-#endif
-
// FIXME: Convert this #if'def to an IDL conditional attribute.
#if defined(WTF_PLATFORM_IOS) && WTF_PLATFORM_IOS
readonly attribute boolean standalone;
@@ -49,3 +33,7 @@
void getStorageUpdates(); // FIXME: Remove this method or rename to yieldForStorageUpdates.
};
+Navigator implements NavigatorConcurrentHardware;
+Navigator implements NavigatorID;
+Navigator implements NavigatorLanguage;
+Navigator implements NavigatorOnLine;
Modified: trunk/Source/WebCore/page/NavigatorBase.cpp (201969 => 201970)
--- trunk/Source/WebCore/page/NavigatorBase.cpp 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WebCore/page/NavigatorBase.cpp 2016-06-11 17:44:20 UTC (rev 201970)
@@ -27,8 +27,11 @@
#include "config.h"
#include "NavigatorBase.h"
+#include "Language.h"
#include "NetworkStateNotifier.h"
+#include <mutex>
#include <wtf/NeverDestroyed.h>
+#include <wtf/NumberOfCores.h>
#include <wtf/text/WTFString.h>
#if OS(LINUX)
@@ -44,30 +47,30 @@
#if PLATFORM(IOS)
#define WEBCORE_NAVIGATOR_PLATFORM deviceName()
#elif OS(MAC_OS_X) && (CPU(PPC) || CPU(PPC64))
-#define WEBCORE_NAVIGATOR_PLATFORM "MacPPC"
+#define WEBCORE_NAVIGATOR_PLATFORM ASCIILiteral("MacPPC")
#elif OS(MAC_OS_X) && (CPU(X86) || CPU(X86_64))
-#define WEBCORE_NAVIGATOR_PLATFORM "MacIntel"
+#define WEBCORE_NAVIGATOR_PLATFORM ASCIILiteral("MacIntel")
#elif OS(WINDOWS)
-#define WEBCORE_NAVIGATOR_PLATFORM "Win32"
+#define WEBCORE_NAVIGATOR_PLATFORM ASCIILiteral("Win32")
#else
-#define WEBCORE_NAVIGATOR_PLATFORM ""
+#define WEBCORE_NAVIGATOR_PLATFORM emptyString()
#endif
#endif // ifndef WEBCORE_NAVIGATOR_PLATFORM
#ifndef WEBCORE_NAVIGATOR_PRODUCT
-#define WEBCORE_NAVIGATOR_PRODUCT "Gecko"
+#define WEBCORE_NAVIGATOR_PRODUCT ASCIILiteral("Gecko")
#endif // ifndef WEBCORE_NAVIGATOR_PRODUCT
#ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB
-#define WEBCORE_NAVIGATOR_PRODUCT_SUB "20030107"
+#define WEBCORE_NAVIGATOR_PRODUCT_SUB ASCIILiteral("20030107")
#endif // ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB
#ifndef WEBCORE_NAVIGATOR_VENDOR
-#define WEBCORE_NAVIGATOR_VENDOR "Apple Computer, Inc."
+#define WEBCORE_NAVIGATOR_VENDOR ASCIILiteral("Apple Computer, Inc.")
#endif // ifndef WEBCORE_NAVIGATOR_VENDOR
#ifndef WEBCORE_NAVIGATOR_VENDOR_SUB
-#define WEBCORE_NAVIGATOR_VENDOR_SUB ""
+#define WEBCORE_NAVIGATOR_VENDOR_SUB emptyString()
#endif // ifndef WEBCORE_NAVIGATOR_VENDOR_SUB
namespace WebCore {
@@ -76,9 +79,9 @@
{
}
-String NavigatorBase::appName() const
+String NavigatorBase::appName()
{
- return "Netscape";
+ return ASCIILiteral("Netscape");
}
String NavigatorBase::appVersion() const
@@ -88,7 +91,7 @@
return agent.substring(agent.find('/') + 1);
}
-String NavigatorBase::platform() const
+String NavigatorBase::platform()
{
#if OS(LINUX)
if (!String(WEBCORE_NAVIGATOR_PLATFORM).isEmpty())
@@ -101,34 +104,65 @@
#endif
}
-String NavigatorBase::appCodeName() const
+String NavigatorBase::appCodeName()
{
- return "Mozilla";
+ return ASCIILiteral("Mozilla");
}
-String NavigatorBase::product() const
+String NavigatorBase::product()
{
return WEBCORE_NAVIGATOR_PRODUCT;
}
-String NavigatorBase::productSub() const
+String NavigatorBase::productSub()
{
return WEBCORE_NAVIGATOR_PRODUCT_SUB;
}
-String NavigatorBase::vendor() const
+String NavigatorBase::vendor()
{
return WEBCORE_NAVIGATOR_VENDOR;
}
-String NavigatorBase::vendorSub() const
+String NavigatorBase::vendorSub()
{
return WEBCORE_NAVIGATOR_VENDOR_SUB;
}
-bool NavigatorBase::onLine() const
+bool NavigatorBase::onLine()
{
return networkStateNotifier().onLine();
}
+String NavigatorBase::language()
+{
+ return defaultLanguage();
+}
+
+#if ENABLE(NAVIGATOR_HWCONCURRENCY)
+
+int NavigatorBase::hardwareConcurrency()
+{
+ static int numberOfCores;
+
+ static std::once_flag once;
+ std::call_once(once, [] {
+ // Enforce a maximum for the number of cores reported to mitigate
+ // fingerprinting for the minority of machines with large numbers of cores.
+ // If machines with more than 8 cores become commonplace, we should bump this number.
+ // see https://bugs.webkit.org/show_bug.cgi?id=132588 for the
+ // rationale behind this decision.
+#if PLATFORM(IOS)
+ const int maxCoresToReport = 2;
+#else
+ const int maxCoresToReport = 8;
+#endif
+ numberOfCores = std::min(WTF::numberOfProcessorCores(), maxCoresToReport);
+ });
+
+ return numberOfCores;
+}
+
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebCore/page/NavigatorBase.h (201969 => 201970)
--- trunk/Source/WebCore/page/NavigatorBase.h 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WebCore/page/NavigatorBase.h 2016-06-11 17:44:20 UTC (rev 201970)
@@ -30,25 +30,31 @@
namespace WebCore {
- class NavigatorBase {
- public:
- String appName() const;
- String appVersion() const;
- virtual String userAgent() const = 0;
- String platform() const;
+class NavigatorBase {
+public:
+ static String appName();
+ String appVersion() const;
+ virtual String userAgent() const = 0;
+ static String platform();
- String appCodeName() const;
- String product() const;
- String productSub() const;
- String vendor() const;
- String vendorSub() const;
+ static String appCodeName();
+ static String product();
+ static String productSub();
+ static String vendor();
+ static String vendorSub();
- bool onLine() const;
+ static bool onLine();
- protected:
- virtual ~NavigatorBase();
- };
+ static String language();
+#if ENABLE(NAVIGATOR_HWCONCURRENCY)
+ static int hardwareConcurrency();
+#endif
+
+protected:
+ virtual ~NavigatorBase();
+};
+
} // namespace WebCore
#endif // NavigatorBase_h
Copied: trunk/Source/WebCore/page/NavigatorConcurrentHardware.idl (from rev 201969, trunk/Source/WebCore/page/WorkerNavigator.idl) (0 => 201970)
--- trunk/Source/WebCore/page/NavigatorConcurrentHardware.idl (rev 0)
+++ trunk/Source/WebCore/page/NavigatorConcurrentHardware.idl 2016-06-11 17:44:20 UTC (rev 201970)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ NoInterfaceObject
+] interface NavigatorConcurrentHardware {
+ [Conditional=NAVIGATOR_HWCONCURRENCY] readonly attribute unsigned long long hardwareConcurrency;
+};
Copied: trunk/Source/WebCore/page/NavigatorID.idl (from rev 201969, trunk/Source/WebCore/page/WorkerNavigator.idl) (0 => 201970)
--- trunk/Source/WebCore/page/NavigatorID.idl (rev 0)
+++ trunk/Source/WebCore/page/NavigatorID.idl 2016-06-11 17:44:20 UTC (rev 201970)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ NoInterfaceObject
+] interface NavigatorID {
+ [Nondeterministic] readonly attribute DOMString appCodeName;
+ [Nondeterministic] readonly attribute DOMString appName;
+ [Nondeterministic] readonly attribute DOMString appVersion;
+ [Nondeterministic] readonly attribute DOMString platform;
+ [Nondeterministic] readonly attribute DOMString product;
+ [Nondeterministic] readonly attribute DOMString productSub;
+ [Nondeterministic] readonly attribute DOMString userAgent;
+ [Nondeterministic] readonly attribute DOMString vendor;
+ [Nondeterministic] readonly attribute DOMString vendorSub;
+};
Copied: trunk/Source/WebCore/page/NavigatorLanguage.idl (from rev 201969, trunk/Source/WebCore/page/WorkerNavigator.idl) (0 => 201970)
--- trunk/Source/WebCore/page/NavigatorLanguage.idl (rev 0)
+++ trunk/Source/WebCore/page/NavigatorLanguage.idl 2016-06-11 17:44:20 UTC (rev 201970)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ NoInterfaceObject
+] interface NavigatorLanguage {
+ [Nondeterministic] readonly attribute DOMString language;
+ // readonly attribute FrozenArray<DOMString> languages;
+};
Copied: trunk/Source/WebCore/page/NavigatorOnLine.idl (from rev 201969, trunk/Source/WebCore/page/WorkerNavigator.idl) (0 => 201970)
--- trunk/Source/WebCore/page/NavigatorOnLine.idl (rev 0)
+++ trunk/Source/WebCore/page/NavigatorOnLine.idl 2016-06-11 17:44:20 UTC (rev 201970)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ NoInterfaceObject
+] interface NavigatorOnLine {
+ readonly attribute boolean onLine;
+};
Modified: trunk/Source/WebCore/page/WorkerNavigator.idl (201969 => 201970)
--- trunk/Source/WebCore/page/WorkerNavigator.idl 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WebCore/page/WorkerNavigator.idl 2016-06-11 17:44:20 UTC (rev 201970)
@@ -30,11 +30,9 @@
Exposed=Worker,
GenerateIsReachable=Impl,
] interface WorkerNavigator {
- readonly attribute DOMString appName;
- readonly attribute DOMString appVersion;
- readonly attribute DOMString platform;
- readonly attribute DOMString userAgent;
-
- readonly attribute boolean onLine;
};
+WorkerNavigator implements NavigatorConcurrentHardware;
+WorkerNavigator implements NavigatorID;
+WorkerNavigator implements NavigatorLanguage;
+WorkerNavigator implements NavigatorOnLine;
Modified: trunk/Source/WebCore/platform/Language.cpp (201969 => 201970)
--- trunk/Source/WebCore/platform/Language.cpp 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WebCore/platform/Language.cpp 2016-06-11 17:44:20 UTC (rev 201970)
@@ -38,6 +38,8 @@
namespace WebCore {
+static StaticLock userPreferredLanguagesMutex;
+
static void registerLanguageDidChangeCallbackIfNecessary()
{
static std::once_flag once;
@@ -100,11 +102,23 @@
languageDidChange();
}
+static Vector<String> isolatedCopy(const Vector<String>& strings)
+{
+ Vector<String> copy;
+ copy.reserveInitialCapacity(strings.size());
+ for (auto& language : strings)
+ copy.uncheckedAppend(language.isolatedCopy());
+ return copy;
+}
+
Vector<String> userPreferredLanguages()
{
- Vector<String>& override = preferredLanguagesOverride();
- if (!override.isEmpty())
- return override;
+ {
+ std::lock_guard<StaticLock> lock(userPreferredLanguagesMutex);
+ Vector<String>& override = preferredLanguagesOverride();
+ if (!override.isEmpty())
+ return isolatedCopy(override);
+ }
registerLanguageDidChangeCallbackIfNecessary();
return platformUserPreferredLanguages();
Modified: trunk/Source/WebCore/platform/Language.h (201969 => 201970)
--- trunk/Source/WebCore/platform/Language.h 2016-06-11 11:46:19 UTC (rev 201969)
+++ trunk/Source/WebCore/platform/Language.h 2016-06-11 17:44:20 UTC (rev 201970)
@@ -31,8 +31,8 @@
namespace WebCore {
-WEBCORE_EXPORT String defaultLanguage();
-WEBCORE_EXPORT Vector<String> userPreferredLanguages();
+WEBCORE_EXPORT String defaultLanguage(); // Thread-safe.
+WEBCORE_EXPORT Vector<String> userPreferredLanguages(); // Thread-safe.
Vector<String> userPreferredLanguagesOverride();
WEBCORE_EXPORT void overrideUserPreferredLanguages(const Vector<String>&);
size_t indexOfBestMatchingLanguageInList(const String& language, const Vector<String>& languageList, bool& exactMatch);