[tbb-commits] [tor-browser/tor-browser-31.1.1esr-4.x-1] Bug 13027: Backport of Navigator.* spoofing patch.

mikeperry at torproject.org mikeperry at torproject.org
Thu Oct 9 06:57:32 UTC 2014


commit 30f92a25d4f0629285d9f64c6ce090dfda3a252f
Author: Georg Koppen <gk at torproject.org>
Date:   Mon Oct 6 12:02:39 2014 +0000

    Bug 13027: Backport of Navigator.* spoofing patch.
    
    It turned out Web Workers ignored general.*.override values which
    got fixed by Mozilla with
    https://hg.mozilla.org/mozilla-central/rev/b0b831a03d9ch
    https://hg.mozilla.org/mozilla-central/rev/eeb169601087 (bug 1062920
    and 1060621).
    
    This is an ESR 31 specific backport which was at least partly
    necessary due to the big worker related patchset (bug 949325) which
    landed in Firefox 32.
---
 dom/base/Navigator.cpp                |   61 ++++++++++---------
 dom/base/Navigator.h                  |   13 +++--
 dom/workers/Navigator.cpp             |   47 ++++++++++++++-
 dom/workers/Navigator.h               |   37 ++++--------
 dom/workers/RuntimeService.cpp        |  104 ++++++++++++++++++++++++++++++++-
 dom/workers/RuntimeService.h          |   12 ++++
 dom/workers/WorkerScope.cpp           |    4 ++
 dom/workers/test/bug1060621_worker.js |    2 +
 dom/workers/test/bug1062920_worker.js |    6 ++
 dom/workers/test/chrome.ini           |    2 +
 dom/workers/test/mochitest.ini        |   11 ++++
 dom/workers/test/test_bug1060621.html |   30 ++++++++++
 dom/workers/test/test_bug1062920.html |   61 +++++++++++++++++++
 dom/workers/test/test_bug1062920.xul  |   68 +++++++++++++++++++++
 14 files changed, 394 insertions(+), 64 deletions(-)

diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp
index 0f03ad3..135550e 100644
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -337,13 +337,13 @@ Navigator::GetAppCodeName(nsAString& aAppCodeName)
 NS_IMETHODIMP
 Navigator::GetAppVersion(nsAString& aAppVersion)
 {
-  return NS_GetNavigatorAppVersion(aAppVersion);
+  return GetAppVersion(aAppVersion, /* aUsePrefOverriddenValue */ true);
 }
 
 NS_IMETHODIMP
 Navigator::GetAppName(nsAString& aAppName)
 {
-  NS_GetNavigatorAppName(aAppName);
+  AppName(aAppName, /* aUsePrefOverriddenValue */ true);
   return NS_OK;
 }
 
@@ -406,7 +406,7 @@ Navigator::GetLanguage(nsAString& aLanguage)
 NS_IMETHODIMP
 Navigator::GetPlatform(nsAString& aPlatform)
 {
-  return NS_GetNavigatorPlatform(aPlatform);
+  return GetPlatform(aPlatform, /* aUsePrefOverriddenValue */ true);
 }
 
 NS_IMETHODIMP
@@ -2356,29 +2356,12 @@ Navigator::GetWindowFromGlobal(JSObject* aGlobal)
   return win.forget();
 }
 
-} // namespace dom
-} // namespace mozilla
-
 nsresult
-NS_GetNavigatorUserAgent(nsAString& aUserAgent)
+Navigator::GetPlatform(nsAString& aPlatform, bool aUsePrefOverriddenValue)
 {
-  nsresult rv;
-
-  nsCOMPtr<nsIHttpProtocolHandler>
-    service(do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsAutoCString ua;
-  rv = service->GetUserAgent(ua);
-  CopyASCIItoUTF16(ua, aUserAgent);
-
-  return rv;
-}
+  MOZ_ASSERT(NS_IsMainThread());
 
-nsresult
-NS_GetNavigatorPlatform(nsAString& aPlatform)
-{
-  if (!nsContentUtils::IsCallerChrome()) {
+  if (aUsePrefOverriddenValue && !nsContentUtils::IsCallerChrome()) {
     const nsAdoptingString& override =
       mozilla::Preferences::GetString("general.platform.override");
 
@@ -2417,10 +2400,11 @@ NS_GetNavigatorPlatform(nsAString& aPlatform)
 
   return rv;
 }
-nsresult
-NS_GetNavigatorAppVersion(nsAString& aAppVersion)
+
+/* static */ nsresult
+Navigator::GetAppVersion(nsAString& aAppVersion, bool aUsePrefOverriddenValue)
 {
-  if (!nsContentUtils::IsCallerChrome()) {
+  if (aUsePrefOverriddenValue && !nsContentUtils::IsCallerChrome()) {
     const nsAdoptingString& override =
       mozilla::Preferences::GetString("general.appversion.override");
 
@@ -2452,10 +2436,10 @@ NS_GetNavigatorAppVersion(nsAString& aAppVersion)
   return rv;
 }
 
-void
-NS_GetNavigatorAppName(nsAString& aAppName)
+/* static */ void
+Navigator::AppName(nsAString& aAppName, bool aUsePrefOverriddenValue)
 {
-  if (!nsContentUtils::IsCallerChrome()) {
+  if (aUsePrefOverriddenValue && !nsContentUtils::IsCallerChrome()) {
     const nsAdoptingString& override =
       mozilla::Preferences::GetString("general.appname.override");
 
@@ -2467,3 +2451,22 @@ NS_GetNavigatorAppName(nsAString& aAppName)
 
   aAppName.AssignLiteral("Netscape");
 }
+
+} // namespace dom
+} // namespace mozilla
+
+nsresult
+NS_GetNavigatorUserAgent(nsAString& aUserAgent)
+{
+  nsresult rv;
+
+  nsCOMPtr<nsIHttpProtocolHandler>
+    service(do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &rv));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  nsAutoCString ua;
+  rv = service->GetUserAgent(ua);
+  CopyASCIItoUTF16(ua, aUserAgent);
+
+  return rv;
+}
diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h
index a4cbf42..8eb9b09 100644
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -46,8 +46,6 @@ class nsIDOMMozIccManager;
 // Navigator: Script "navigator" object
 //*****************************************************************************
 
-void NS_GetNavigatorAppName(nsAString& aAppName);
-
 namespace mozilla {
 namespace dom {
 
@@ -156,6 +154,15 @@ public:
   // The XPCOM GetDoNotTrack is ok
   Geolocation* GetGeolocation(ErrorResult& aRv);
   battery::BatteryManager* GetBattery(ErrorResult& aRv);
+
+  static void AppName(nsAString& aAppName, bool aUsePrefOverriddenValue);
+
+  static nsresult GetPlatform(nsAString& aPlatform,
+                              bool aUsePrefOverriddenValue);
+
+  static nsresult GetAppVersion(nsAString& aAppVersion,
+                                bool aUsePrefOverriddenValue);
+
   already_AddRefed<Promise> GetDataStores(const nsAString &aName,
                                           ErrorResult& aRv);
   bool Vibrate(uint32_t aDuration);
@@ -361,7 +368,5 @@ private:
 } // namespace mozilla
 
 nsresult NS_GetNavigatorUserAgent(nsAString& aUserAgent);
-nsresult NS_GetNavigatorPlatform(nsAString& aPlatform);
-nsresult NS_GetNavigatorAppVersion(nsAString& aAppVersion);
 
 #endif // mozilla_dom_Navigator_h
diff --git a/dom/workers/Navigator.cpp b/dom/workers/Navigator.cpp
index 9db904f..f2604cd 100644
--- a/dom/workers/Navigator.cpp
+++ b/dom/workers/Navigator.cpp
@@ -8,6 +8,7 @@
 #include "mozilla/dom/WorkerNavigatorBinding.h"
 
 #include "RuntimeService.h"
+#include "WorkerPrivate.h"
 
 BEGIN_WORKERS_NAMESPACE
 
@@ -26,9 +27,7 @@ WorkerNavigator::Create(bool aOnLine)
     rts->GetNavigatorProperties();
 
   nsRefPtr<WorkerNavigator> navigator =
-    new WorkerNavigator(properties.mAppName, properties.mAppVersion,
-                        properties.mPlatform, properties.mUserAgent,
-                        aOnLine);
+    new WorkerNavigator(properties, aOnLine);
 
   return navigator.forget();
 }
@@ -39,4 +38,46 @@ WorkerNavigator::WrapObject(JSContext* aCx)
   return WorkerNavigatorBinding_workers::Wrap(aCx, this);
 }
 
+void
+WorkerNavigator::GetAppName(nsString& aAppName) const
+{
+  WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+  MOZ_ASSERT(workerPrivate);
+
+  if (!mProperties.mAppNameOverridden.IsEmpty() &&
+      !workerPrivate->UsesSystemPrincipal()) {
+    aAppName = mProperties.mAppNameOverridden;
+  } else {
+    aAppName = mProperties.mAppName;
+  }
+}
+
+void
+WorkerNavigator::GetAppVersion(nsString& aAppVersion) const
+{
+  WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+  MOZ_ASSERT(workerPrivate);
+
+  if (!mProperties.mAppVersionOverridden.IsEmpty() &&
+      !workerPrivate->UsesSystemPrincipal()) {
+    aAppVersion = mProperties.mAppVersionOverridden;
+  } else {
+    aAppVersion = mProperties.mAppVersion;
+  }
+}
+
+void
+WorkerNavigator::GetPlatform(nsString& aPlatform) const
+{
+  WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+  MOZ_ASSERT(workerPrivate);
+
+  if (!mProperties.mPlatformOverridden.IsEmpty() &&
+      !workerPrivate->UsesSystemPrincipal()) {
+    aPlatform = mProperties.mPlatformOverridden;
+  } else {
+    aPlatform = mProperties.mPlatform;
+  }
+}
+
 END_WORKERS_NAMESPACE
diff --git a/dom/workers/Navigator.h b/dom/workers/Navigator.h
index e5183b3..3b4fb31 100644
--- a/dom/workers/Navigator.h
+++ b/dom/workers/Navigator.h
@@ -7,6 +7,7 @@
 #define mozilla_dom_workers_navigator_h__
 
 #include "Workers.h"
+#include "RuntimeService.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 
@@ -14,21 +15,14 @@ BEGIN_WORKERS_NAMESPACE
 
 class WorkerNavigator MOZ_FINAL : public nsWrapperCache
 {
-  nsString mAppName;
-  nsString mAppVersion;
-  nsString mPlatform;
-  nsString mUserAgent;
+  typedef struct RuntimeService::NavigatorProperties NavigatorProperties;
+
+  NavigatorProperties mProperties;
   bool mOnline;
 
-  WorkerNavigator(const nsAString& aAppName,
-                  const nsAString& aAppVersion,
-                  const nsAString& aPlatform,
-                  const nsAString& aUserAgent,
+  WorkerNavigator(const NavigatorProperties& aProperties,
                   bool aOnline)
-    : mAppName(aAppName)
-    , mAppVersion(aAppVersion)
-    , mPlatform(aPlatform)
-    , mUserAgent(aUserAgent)
+    : mProperties(aProperties)
     , mOnline(aOnline)
   {
     MOZ_COUNT_CTOR(WorkerNavigator);
@@ -59,24 +53,17 @@ public:
   {
     aAppCodeName.AssignLiteral("Mozilla");
   }
-  void GetAppName(nsString& aAppName) const
-  {
-    aAppName = mAppName;
-  }
+  void GetAppName(nsString& aAppName) const;
 
-  void GetAppVersion(nsString& aAppVersion) const
-  {
-    aAppVersion = mAppVersion;
-  }
+  void GetAppVersion(nsString& aAppVersion) const;
+
+  void GetPlatform(nsString& aPlatform) const;
 
-  void GetPlatform(nsString& aPlatform) const
-  {
-    aPlatform = mPlatform;
-  }
   void GetProduct(nsString& aProduct) const
   {
     aProduct.AssignLiteral("Gecko");
   }
+
   bool TaintEnabled() const
   {
     return false;
@@ -84,7 +71,7 @@ public:
 
   void GetUserAgent(nsString& aUserAgent) const
   {
-    aUserAgent = mUserAgent;
+    aUserAgent = mProperties.mUserAgent;
   }
 
   bool OnLine() const
diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
index b34cba3..7eaf007 100644
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -110,6 +110,10 @@ static_assert(MAX_WORKERS_PER_DOMAIN >= 1,
 #define CC_REQUEST_OBSERVER_TOPIC "child-cc-request"
 #define MEMORY_PRESSURE_OBSERVER_TOPIC "memory-pressure"
 
+#define PREF_GENERAL_APPNAME_OVERRIDE "general.appname.override"
+#define PREF_GENERAL_APPVERSION_OVERRIDE "general.appversion.override"
+#define PREF_GENERAL_PLATFORM_OVERRIDE "general.platform.override"
+
 #define BROADCAST_ALL_WORKERS(_func, ...)                                      \
   PR_BEGIN_MACRO                                                               \
     AssertIsOnMainThread();                                                    \
@@ -981,6 +985,48 @@ private:
   }
 };
 
+void
+AppNameOverrideChanged(const char* /* aPrefName */, void* /* aClosure */)
+{
+  AssertIsOnMainThread();
+
+  const nsAdoptingString& override =
+    mozilla::Preferences::GetString(PREF_GENERAL_APPNAME_OVERRIDE);
+
+  RuntimeService* runtime = RuntimeService::GetService();
+  if (runtime) {
+    runtime->UpdateAppNameOverridePreference(override);
+  }
+}
+
+void
+AppVersionOverrideChanged(const char* /* aPrefName */, void* /* aClosure */)
+{
+  AssertIsOnMainThread();
+
+  const nsAdoptingString& override =
+    mozilla::Preferences::GetString(PREF_GENERAL_APPVERSION_OVERRIDE);
+
+  RuntimeService* runtime = RuntimeService::GetService();
+  if (runtime) {
+    runtime->UpdateAppVersionOverridePreference(override);
+  }
+}
+
+void
+PlatformOverrideChanged(const char* /* aPrefName */, void* /* aClosure */)
+{
+  AssertIsOnMainThread();
+
+  const nsAdoptingString& override =
+    mozilla::Preferences::GetString(PREF_GENERAL_PLATFORM_OVERRIDE);
+
+  RuntimeService* runtime = RuntimeService::GetService();
+  if (runtime) {
+    runtime->UpdatePlatformOverridePreference(override);
+  }
+}
+
 } /* anonymous namespace */
 
 class RuntimeService::WorkerThread MOZ_FINAL : public nsThread
@@ -1347,15 +1393,25 @@ RuntimeService::RegisterWorker(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
   }
   else {
     if (!mNavigatorPropertiesLoaded) {
-      NS_GetNavigatorAppName(mNavigatorProperties.mAppName);
-      if (NS_FAILED(NS_GetNavigatorAppVersion(mNavigatorProperties.mAppVersion)) ||
-          NS_FAILED(NS_GetNavigatorPlatform(mNavigatorProperties.mPlatform)) ||
+      Navigator::AppName(mNavigatorProperties.mAppName,
+                         false /* aUsePrefOverriddenValue */);
+      if (NS_FAILED(Navigator::GetAppVersion(mNavigatorProperties.mAppVersion,
+                                             false /* aUsePrefOverriddenValue */)) ||
+          NS_FAILED(Navigator::GetPlatform(mNavigatorProperties.mPlatform,
+                                           false /* aUsePrefOverriddenValue */)) ||
           NS_FAILED(NS_GetNavigatorUserAgent(mNavigatorProperties.mUserAgent))) {
         JS_ReportError(aCx, "Failed to load navigator strings!");
         UnregisterWorker(aCx, aWorkerPrivate);
         return false;
       }
 
+      mNavigatorProperties.mAppNameOverridden =
+        mozilla::Preferences::GetString(PREF_GENERAL_APPNAME_OVERRIDE);
+      mNavigatorProperties.mAppVersionOverridden =
+        mozilla::Preferences::GetString(PREF_GENERAL_APPVERSION_OVERRIDE);
+      mNavigatorProperties.mPlatformOverridden =
+        mozilla::Preferences::GetString(PREF_GENERAL_PLATFORM_OVERRIDE);
+
       mNavigatorPropertiesLoaded = true;
     }
 
@@ -1696,6 +1752,18 @@ RuntimeService::Init()
                                                    PREF_WORKERS_OPTIONS_PREFIX,
                                                    nullptr)) ||
       NS_FAILED(Preferences::RegisterCallbackAndCall(
+                                                  AppNameOverrideChanged,
+                                                  PREF_GENERAL_APPNAME_OVERRIDE,
+                                                  nullptr)) ||
+      NS_FAILED(Preferences::RegisterCallbackAndCall(
+                                               AppVersionOverrideChanged,
+                                               PREF_GENERAL_APPVERSION_OVERRIDE,
+                                               nullptr)) ||
+      NS_FAILED(Preferences::RegisterCallbackAndCall(
+                                                 PlatformOverrideChanged,
+                                                 PREF_GENERAL_PLATFORM_OVERRIDE,
+                                                 nullptr)) ||
+      NS_FAILED(Preferences::RegisterCallbackAndCall(
                                                  JSVersionChanged,
                                                  PREF_WORKERS_LATEST_JS_VERSION,
                                                  nullptr))) {
@@ -1841,6 +1909,15 @@ RuntimeService::Cleanup()
     if (NS_FAILED(Preferences::UnregisterCallback(JSVersionChanged,
                                                   PREF_WORKERS_LATEST_JS_VERSION,
                                                   nullptr)) ||
+        NS_FAILED(Preferences::UnregisterCallback(AppNameOverrideChanged,
+                                                  PREF_GENERAL_APPNAME_OVERRIDE,
+                                                  nullptr)) ||
+        NS_FAILED(Preferences::UnregisterCallback(AppVersionOverrideChanged,
+                                                  PREF_GENERAL_APPVERSION_OVERRIDE,
+                                                  nullptr)) ||
+        NS_FAILED(Preferences::UnregisterCallback(PlatformOverrideChanged,
+                                                  PREF_GENERAL_PLATFORM_OVERRIDE,
+                                                  nullptr)) ||
         NS_FAILED(Preferences::UnregisterCallback(LoadRuntimeAndContextOptions,
                                                   PREF_JS_OPTIONS_PREFIX,
                                                   nullptr)) ||
@@ -2235,6 +2312,27 @@ RuntimeService::UpdateAllWorkerRuntimeAndContextOptions()
 }
 
 void
+RuntimeService::UpdateAppNameOverridePreference(const nsAString& aValue)
+{
+  AssertIsOnMainThread();
+  mNavigatorProperties.mAppNameOverridden = aValue;
+}
+
+void
+RuntimeService::UpdateAppVersionOverridePreference(const nsAString& aValue)
+{
+  AssertIsOnMainThread();
+  mNavigatorProperties.mAppVersionOverridden = aValue;
+}
+
+void
+RuntimeService::UpdatePlatformOverridePreference(const nsAString& aValue)
+{
+  AssertIsOnMainThread();
+  mNavigatorProperties.mPlatformOverridden = aValue;
+}
+
+void
 RuntimeService::UpdateAllWorkerPreference(WorkerPreference aPref, bool aValue)
 {
   BROADCAST_ALL_WORKERS(UpdatePreference, aPref, aValue);
diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h
index 9f81fd3..625b577 100644
--- a/dom/workers/RuntimeService.h
+++ b/dom/workers/RuntimeService.h
@@ -103,8 +103,11 @@ public:
   struct NavigatorProperties
   {
     nsString mAppName;
+    nsString mAppNameOverridden;
     nsString mAppVersion;
+    nsString mAppVersionOverridden;
     nsString mPlatform;
+    nsString mPlatformOverridden;
     nsString mUserAgent;
   };
 
@@ -186,6 +189,15 @@ public:
   }
 
   void
+  UpdateAppNameOverridePreference(const nsAString& aValue);
+
+  void
+  UpdateAppVersionOverridePreference(const nsAString& aValue);
+
+  void
+  UpdatePlatformOverridePreference(const nsAString& aValue);
+
+  void
   UpdateAllWorkerRuntimeAndContextOptions();
 
   void
diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp
index 04d8f92..77e0978 100644
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -52,11 +52,15 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(WorkerGlobalScope)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(WorkerGlobalScope,
                                                   DOMEventTargetHelper)
   tmp->mWorkerPrivate->AssertIsOnWorkerThread();
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocation)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNavigator)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(WorkerGlobalScope,
                                                 DOMEventTargetHelper)
   tmp->mWorkerPrivate->AssertIsOnWorkerThread();
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mLocation)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mNavigator)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(WorkerGlobalScope,
diff --git a/dom/workers/test/bug1060621_worker.js b/dom/workers/test/bug1060621_worker.js
new file mode 100644
index 0000000..a0fcd3f
--- /dev/null
+++ b/dom/workers/test/bug1060621_worker.js
@@ -0,0 +1,2 @@
+navigator.foobar = 42;
+postMessage('done');
diff --git a/dom/workers/test/bug1062920_worker.js b/dom/workers/test/bug1062920_worker.js
new file mode 100644
index 0000000..d3df388
--- /dev/null
+++ b/dom/workers/test/bug1062920_worker.js
@@ -0,0 +1,6 @@
+postMessage({ appCodeName: navigator.appCodeName,
+              appName: navigator.appName,
+              appVersion: navigator.appVersion,
+              platform: navigator.platform,
+              userAgent: navigator.userAgent,
+              product: navigator.product });
diff --git a/dom/workers/test/chrome.ini b/dom/workers/test/chrome.ini
index 2420141..c4acacb 100644
--- a/dom/workers/test/chrome.ini
+++ b/dom/workers/test/chrome.ini
@@ -18,6 +18,7 @@ support-files =
   jsm_url_worker.js
   workersDisabled_worker.js
   file_url.jsm
+  bug1062920_worker.js
 
 [test_bug883784.jsm]
 [test_bug883784.xul]
@@ -36,3 +37,4 @@ support-files =
 [test_fileSubWorker.xul]
 [test_workersDisabled.xul]
 [test_url.xul]
+[test_bug1062920.xul]
diff --git a/dom/workers/test/mochitest.ini b/dom/workers/test/mochitest.ini
index 5107604..0275195 100644
--- a/dom/workers/test/mochitest.ini
+++ b/dom/workers/test/mochitest.ini
@@ -73,6 +73,8 @@ support-files =
   subdir/relativeLoad_sub_worker.js
   subdir/relativeLoad_sub_worker2.js
   subdir/relativeLoad_sub_import.js
+  bug1060621_worker.js
+  bug1062920_worker.js
 
 [test_404.html]
 [test_atob.html]
@@ -155,3 +157,12 @@ skip-if = buildapp == 'b2g' || e10s
 skip-if = (os == "win") || (os == "mac") || toolkit == 'android' || e10s #bug 798220
 [test_url_exceptions.html]
 [test_urlSearchParams.html]
+<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+[test_bug1060621.html]
+[test_bug1062920.html]
+>>>>>>> Bug 1062920 - WorkerNavigator strings should honor general.*.override prefs. r=khuey, a=sledru
+=======
+[test_bug1060621.html]
+>>>>>>> Bug 1060621 - WorkerScope should CC mLocation and mNavigator. r=bz, a=sledru
diff --git a/dom/workers/test/test_bug1060621.html b/dom/workers/test/test_bug1060621.html
new file mode 100644
index 0000000..758bf99
--- /dev/null
+++ b/dom/workers/test/test_bug1060621.html
@@ -0,0 +1,30 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for URLSearchParams object in workers</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test"></pre>
+<script class="testbody" type="text/javascript">
+
+  var worker = new Worker("bug1060621_worker.js");
+
+  worker.onmessage = function(event) {
+    ok(true, "The operation is done. We should not leak.");
+    SimpleTest.finish();
+  };
+
+  SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/workers/test/test_bug1062920.html b/dom/workers/test/test_bug1062920.html
new file mode 100644
index 0000000..f3afca9
--- /dev/null
+++ b/dom/workers/test/test_bug1062920.html
@@ -0,0 +1,61 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for navigator property override</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test"></pre>
+<script class="testbody" type="text/javascript">
+
+  function checkValues() {
+    var worker = new Worker("bug1062920_worker.js");
+
+    worker.onmessage = function(event) {
+      is(event.data.appCodeName, navigator.appCodeName, "appCodeName should match");
+      is(event.data.appName, navigator.appName, "appName should match");
+      is(event.data.appVersion, navigator.appVersion, "appVersion should match");
+      is(event.data.platform, navigator.platform, "platform should match");
+      is(event.data.userAgent, navigator.userAgent, "userAgent should match");
+      is(event.data.product, navigator.product, "product should match");
+      runTests();
+    };
+  }
+
+  function replaceAndCheckValues() {
+    SpecialPowers.pushPrefEnv({"set": [
+      ["general.appname.override", "appName overridden"],
+      ["general.appversion.override", "appVersion overridden"],
+      ["general.platform.override", "platform overridden"]
+    ]}, checkValues);
+  }
+
+  var tests = [
+    checkValues,
+    replaceAndCheckValues
+  ];
+
+  function runTests() {
+    if (tests.length == 0) {
+      SimpleTest.finish();
+      return;
+    }
+
+    var test = tests.shift();
+    test();
+  }
+
+  SimpleTest.waitForExplicitFinish();
+  runTests();
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/workers/test/test_bug1062920.xul b/dom/workers/test/test_bug1062920.xul
new file mode 100644
index 0000000..a98d930
--- /dev/null
+++ b/dom/workers/test/test_bug1062920.xul
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<window title="DOM Worker Threads Test"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript" src="dom_worker_helper.js"/>
+
+  <script type="application/javascript">
+
+  function checkValues() {
+    var worker = new Worker("bug1062920_worker.js");
+
+    worker.onmessage = function(event) {
+      is(event.data.appCodeName, navigator.appCodeName, "appCodeName should match");
+      is(event.data.appName, navigator.appName, "appName should match");
+      isnot(event.data.appName, "appName overridden", "appName is not overridden");
+      is(event.data.appVersion, navigator.appVersion, "appVersion should match");
+      isnot(event.data.appVersion, "appVersion overridden", "appVersion is not overridden");
+      is(event.data.platform, navigator.platform, "platform should match");
+      isnot(event.data.platform, "platform overridden", "platform is not overridden");
+      is(event.data.userAgent, navigator.userAgent, "userAgent should match");
+      is(event.data.product, navigator.product, "product should match");
+      runTests();
+    };
+  }
+
+  function replaceAndCheckValues() {
+    SpecialPowers.pushPrefEnv({"set": [
+      ["general.appname.override", "appName overridden"],
+      ["general.appversion.override", "appVersion overridden"],
+      ["general.platform.override", "platform overridden"]
+    ]}, checkValues);
+  }
+
+  var tests = [
+    checkValues,
+    replaceAndCheckValues
+  ];
+
+  function runTests() {
+    if (tests.length == 0) {
+      SimpleTest.finish();
+      return;
+    }
+
+    var test = tests.shift();
+    test();
+  }
+
+  SimpleTest.waitForExplicitFinish();
+  runTests();
+
+  </script>
+
+  <body xmlns="http://www.w3.org/1999/xhtml">
+    <p id="display"></p>
+    <div id="content" style="display:none;"></div>
+    <pre id="test"></pre>
+  </body>
+  <label id="test-result"/>
+</window>





More information about the tbb-commits mailing list