Bug 1523262 Part 2 - Provide atob/btoa in worker debugger scope, r=lsmyth,baku.
authorBrian Hackett <bhackett1024@gmail.com>
Thu, 21 Feb 2019 17:25:39 -1000
changeset 461856 4aa22c4f4c7b7ffd113043b6e4662eacb4af9f3c
parent 461855 7c6b5ef243de9ac32ef4427424dd5f237050515a
child 461857 4047bcadec730528dab1b651ee679ac11f42c41c
push id35631
push userrgurzau@mozilla.com
push dateFri, 01 Mar 2019 13:06:03 +0000
treeherdermozilla-central@d4e19870e27f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsmyth, baku
bugs1523262
milestone67.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 1523262 Part 2 - Provide atob/btoa in worker debugger scope, r=lsmyth,baku.
devtools/shared/worker/loader.js
dom/webidl/WorkerDebuggerGlobalScope.webidl
dom/workers/WorkerScope.cpp
dom/workers/WorkerScope.h
--- a/devtools/shared/worker/loader.js
+++ b/devtools/shared/worker/loader.js
@@ -560,16 +560,18 @@ this.worker = new WorkerDebuggerLoader({
     "rpc": rpc,
     "URL": URL,
     "setImmediate": setImmediate,
     "lazyRequire": lazyRequire,
     "lazyRequireModule": lazyRequireModule,
     "retrieveConsoleEvents": this.retrieveConsoleEvents,
     "setConsoleEventHandler": this.setConsoleEventHandler,
     "console": console,
+    "btoa": this.btoa,
+    "atob": this.atob,
   },
   loadSubScript: loadSubScript,
   modules: {
     "Debugger": Debugger,
     "Services": Object.create(null),
     "chrome": chrome,
     "xpcInspector": xpcInspector,
   },
--- a/dom/webidl/WorkerDebuggerGlobalScope.webidl
+++ b/dom/webidl/WorkerDebuggerGlobalScope.webidl
@@ -27,14 +27,20 @@ interface WorkerDebuggerGlobalScope : Ev
 
   void reportError(DOMString message);
 
   [Throws]
   sequence<any> retrieveConsoleEvents();
 
   [Throws]
   void setConsoleEventHandler(AnyCallback? handler);
+
+  // base64 utility methods
+  [Throws]
+  DOMString btoa(DOMString btoa);
+  [Throws]
+  DOMString atob(DOMString atob);
 };
 
 // So you can debug while you debug
 partial interface WorkerDebuggerGlobalScope {
   void dump(optional DOMString string);
 };
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -971,16 +971,28 @@ already_AddRefed<Console> WorkerDebugger
 void WorkerDebuggerGlobalScope::Dump(JSContext* aCx,
                                      const Optional<nsAString>& aString) const {
   WorkerGlobalScope* scope = mWorkerPrivate->GetOrCreateGlobalScope(aCx);
   if (scope) {
     scope->Dump(aString);
   }
 }
 
+void WorkerDebuggerGlobalScope::Atob(const nsAString& aAtob, nsAString& aOutput,
+                                     ErrorResult& aRv) const {
+  mWorkerPrivate->AssertIsOnWorkerThread();
+  aRv = nsContentUtils::Atob(aAtob, aOutput);
+}
+
+void WorkerDebuggerGlobalScope::Btoa(const nsAString& aBtoa, nsAString& aOutput,
+                                     ErrorResult& aRv) const {
+  mWorkerPrivate->AssertIsOnWorkerThread();
+  aRv = nsContentUtils::Btoa(aBtoa, aOutput);
+}
+
 nsresult WorkerDebuggerGlobalScope::Dispatch(
     TaskCategory aCategory, already_AddRefed<nsIRunnable>&& aRunnable) {
   return EventTargetFor(aCategory)->Dispatch(std::move(aRunnable),
                                              NS_DISPATCH_NORMAL);
 }
 
 nsISerialEventTarget* WorkerDebuggerGlobalScope::EventTargetFor(
     TaskCategory aCategory) const {
--- a/dom/workers/WorkerScope.h
+++ b/dom/workers/WorkerScope.h
@@ -332,16 +332,19 @@ class WorkerDebuggerGlobalScope final : 
                               ErrorResult& aRv);
 
   already_AddRefed<Console> GetConsole(ErrorResult& aRv);
 
   Console* GetConsoleIfExists() const { return mConsole; }
 
   void Dump(JSContext* aCx, const Optional<nsAString>& aString) const;
 
+  void Atob(const nsAString& aAtob, nsAString& aOutput, ErrorResult& aRv) const;
+  void Btoa(const nsAString& aBtoa, nsAString& aOutput, ErrorResult& aRv) const;
+
   // Override DispatchTrait API to target the worker thread.  Dispatch may
   // return failure if the worker thread is not alive.
   nsresult Dispatch(TaskCategory aCategory,
                     already_AddRefed<nsIRunnable>&& aRunnable) override;
 
   nsISerialEventTarget* EventTargetFor(TaskCategory aCategory) const override;
 
   AbstractThread* AbstractMainThreadFor(TaskCategory aCategory) override;