Bug 1442313 part 2. Push down the value of xpc::IsInAutomation into workers. r=bkelly
☠☠ backed out by accb1b3cf593 ☠ ☠
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 01 Mar 2018 14:24:20 -0500
changeset 406078 9788a46b8874dbc1a785e9eef091a9fc2e0b4f36
parent 406077 8fc2c103027ba37bd50dec5e2fe8b79d3d68c28c
child 406079 660332ce1bf08699ce4cbf9aa50a7921850a1cd0
push id100362
push userbzbarsky@mozilla.com
push dateThu, 01 Mar 2018 20:29:12 +0000
treeherdermozilla-inbound@b89286a88588 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1442313
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1442313 part 2. Push down the value of xpc::IsInAutomation into workers. r=bkelly MozReview-Commit-ID: 5h51oqaf0R
dom/workers/WorkerPrivate.cpp
dom/workers/WorkerPrivate.h
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -2612,31 +2612,34 @@ WorkerPrivate::WorkerPrivate(WorkerPriva
   , mWorkerScriptExecutedSuccessfully(false)
   , mFetchHandlerWasAdded(false)
   , mOnLine(false)
   , mMainThreadObjectsForgotten(false)
   , mIsChromeWorker(aIsChromeWorker)
   , mParentFrozen(false)
   , mIsSecureContext(false)
   , mDebuggerRegistered(false)
+  , mIsInAutomation(false)
 {
   MOZ_ASSERT_IF(!IsDedicatedWorker(), NS_IsMainThread());
   mLoadInfo.StealFrom(aLoadInfo);
 
   if (aParent) {
     aParent->AssertIsOnWorkerThread();
 
     // Note that this copies our parent's secure context state into mJSSettings.
     aParent->CopyJSSettings(mJSSettings);
 
     // And manually set our mIsSecureContext, though it's not really relevant to
     // dedicated workers...
     mIsSecureContext = aParent->IsSecureContext();
     MOZ_ASSERT_IF(mIsChromeWorker, mIsSecureContext);
 
+    mIsInAutomation = aParent->IsInAutomation();
+
     MOZ_ASSERT(IsDedicatedWorker());
 
     if (aParent->mParentFrozen) {
       Freeze(nullptr);
     }
 
     mOnLine = aParent->OnLine();
   }
@@ -2660,16 +2663,18 @@ WorkerPrivate::WorkerPrivate(WorkerPriva
 
     if (mIsSecureContext) {
       mJSSettings.chrome.compartmentOptions
                  .creationOptions().setSecureContext(true);
       mJSSettings.content.compartmentOptions
                  .creationOptions().setSecureContext(true);
     }
 
+    mIsInAutomation = xpc::IsInAutomation();
+
     // Our parent can get suspended after it initiates the async creation
     // of a new worker thread.  In this case suspend the new worker as well.
     if (mLoadInfo.mWindow && mLoadInfo.mWindow->IsSuspended()) {
       ParentWindowPaused();
     }
 
     if (mLoadInfo.mWindow && mLoadInfo.mWindow->IsFrozen()) {
       Freeze(mLoadInfo.mWindow);
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -628,16 +628,22 @@ public:
   // compartment of the worker global.  The only reason we don't
   // AssertIsOnParentThread() here is so we can assert that this value matches
   // the one on the compartment, which has to be done from the worker thread.
   bool IsSecureContext() const
   {
     return mIsSecureContext;
   }
 
+  // Check whether we're running in automation.
+  bool IsInAutomation() const
+  {
+    return mIsInAutomation;
+  }
+
   TimeStamp CreationTimeStamp() const
   {
     return mCreationTimeStamp;
   }
 
   DOMHighResTimeStamp CreationTime() const
   {
     return mCreationTimeHighRes;
@@ -1474,16 +1480,20 @@ private:
   // of state (loadinfo, worker type, parent).
   //
   // It's a bit unfortunate that we have to have an out-of-band boolean for
   // this, but we need access to this state from the parent thread, and we can't
   // use our global object's secure state there.
   bool mIsSecureContext;
 
   bool mDebuggerRegistered;
+
+  // mIsInAutomation is true when we're running in test automation.
+  // We expose some extra testing functions in that case.
+  bool mIsInAutomation;
 };
 
 class AutoSyncLoopHolder
 {
   WorkerPrivate* mWorkerPrivate;
   nsCOMPtr<nsIEventTarget> mTarget;
   uint32_t mIndex;