tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WorkerTestUtils.h (2002B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_WorkerTestUtils__
      8 #define mozilla_dom_WorkerTestUtils__
      9 
     10 #include "nsStringFwd.h"
     11 
     12 namespace mozilla {
     13 
     14 class ErrorResult;
     15 
     16 namespace dom {
     17 
     18 class GlobalObject;
     19 class WorkerTestCallback;
     20 
     21 /**
     22 * dom/webidl/WorkerTestUtils.webidl defines APIs to expose worker's internal
     23 * status for glass-box testing. The APIs are only exposed to Workers with prefs
     24 * dom.workers.testing.enabled.
     25 *
     26 * WorkerTestUtils is the implementation of dom/webidl/WorkerTestUtils.webidl
     27 */
     28 class WorkerTestUtils final {
     29 public:
     30  /**
     31   *  Expose the worker's current timer nesting level.
     32   *
     33   *  The worker's current timer nesting level means the executing timer
     34   *  handler's timer nesting level. When there is no executing timer handler, 0
     35   *  should be returned by this API. The maximum timer nesting level is 5.
     36   *
     37   *  https://html.spec.whatwg.org/#timer-initialisation-steps
     38   */
     39  static uint32_t CurrentTimerNestingLevel(const GlobalObject&,
     40                                           ErrorResult& aErr);
     41 
     42  static bool IsRunningInBackground(const GlobalObject&, ErrorResult& aErr);
     43 
     44  static void HoldStrongWorkerRefUntilMainThreadObserverNotified(
     45      const GlobalObject&, const nsACString& aTopic, ErrorResult& aErr);
     46 
     47  MOZ_CAN_RUN_SCRIPT static void BlockUntilMainThreadObserverNotified(
     48      const GlobalObject&, const nsACString& aTopic,
     49      WorkerTestCallback& aWhenObserving, ErrorResult& aErr);
     50 
     51  static void NotifyObserverOnMainThread(const GlobalObject&,
     52                                         const nsACString& aTopic,
     53                                         ErrorResult& aErr);
     54 };
     55 
     56 }  // namespace dom
     57 }  // namespace mozilla
     58 #endif