Bug 1442313 part 3. Expose, test-only, getJSTestingFunctions() in workers. r=bkelly

MozReview-Commit-ID: LiErRvJ6CTH
This commit is contained in:
Boris Zbarsky 2018-03-01 14:24:20 -05:00
Родитель 3f718c4054
Коммит 9a576eb44d
3 изменённых файлов: 29 добавлений и 0 удалений

Просмотреть файл

@ -43,4 +43,7 @@ partial interface WorkerGlobalScope {
// XXXbz no spec for this yet, because the webperf WG is a bit dysfunctional
[Constant, Cached]
readonly attribute Performance performance;
[Func="WorkerGlobalScope::IsInAutomation", Throws]
object getJSTestingFunctions();
};

Просмотреть файл

@ -7,6 +7,7 @@
#include "WorkerScope.h"
#include "jsapi.h"
#include "jsfriendapi.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/Clients.h"
@ -400,6 +401,26 @@ WorkerGlobalScope::GetPerformance()
return mPerformance;
}
bool
WorkerGlobalScope::IsInAutomation(JSContext* aCx, JSObject* /* unused */)
{
return GetWorkerPrivateFromContext(aCx)->IsInAutomation();
}
void
WorkerGlobalScope::GetJSTestingFunctions(JSContext* aCx,
JS::MutableHandle<JSObject*> aFunctions,
ErrorResult& aRv)
{
JSObject* obj = js::GetTestingFunctions(aCx);
if (!obj) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
aFunctions.set(obj);
}
already_AddRefed<Promise>
WorkerGlobalScope::Fetch(const RequestOrUSVString& aInput,
const RequestInit& aInit,

Просмотреть файл

@ -161,6 +161,11 @@ public:
return mPerformance;
}
static bool IsInAutomation(JSContext* aCx, JSObject* /* unused */);
void GetJSTestingFunctions(JSContext* aCx,
JS::MutableHandle<JSObject*> aFunctions,
ErrorResult& aRv);
already_AddRefed<Promise>
Fetch(const RequestOrUSVString& aInput, const RequestInit& aInit,
CallerType aCallerType, ErrorResult& aRv);