Skip to content

Commit

Permalink
Bug 1745352 - Expose IOUtils and PathUtils via Cu.importGlobalPropert…
Browse files Browse the repository at this point in the history
…ies r=nika

PathUtils is the only binding requires for this patch, but eventually we'll
have to migrate NativeManifests.jsm to IOUtils and then we will have to provide
it anyway.

Differential Revision: https://phabricator.services.mozilla.com/D136433
  • Loading branch information
brennie committed Jan 25, 2022
1 parent ba26d88 commit 46c935e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions js/xpconnect/src/Sandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@
#include "mozilla/dom/Fetch.h"
#include "mozilla/dom/FileBinding.h"
#include "mozilla/dom/HeadersBinding.h"
#include "mozilla/dom/IOUtilsBinding.h"
#include "mozilla/dom/InspectorUtilsBinding.h"
#include "mozilla/dom/MessageChannelBinding.h"
#include "mozilla/dom/MessagePortBinding.h"
#include "mozilla/dom/NodeBinding.h"
#include "mozilla/dom/NodeFilterBinding.h"
#include "mozilla/dom/PathUtilsBinding.h"
#include "mozilla/dom/PerformanceBinding.h"
#include "mozilla/dom/PromiseBinding.h"
#include "mozilla/dom/PromiseDebuggingBinding.h"
Expand Down Expand Up @@ -920,6 +922,8 @@ bool xpc::GlobalProperties::Parse(JSContext* cx, JS::HandleObject obj) {
FormData = true;
} else if (JS_LinearStringEqualsLiteral(nameStr, "Headers")) {
Headers = true;
} else if (JS_LinearStringEqualsLiteral(nameStr, "IOUtils")) {
IOUtils = true;
} else if (JS_LinearStringEqualsLiteral(nameStr, "InspectorUtils")) {
InspectorUtils = true;
} else if (JS_LinearStringEqualsLiteral(nameStr, "MessageChannel")) {
Expand All @@ -928,6 +932,8 @@ bool xpc::GlobalProperties::Parse(JSContext* cx, JS::HandleObject obj) {
Node = true;
} else if (JS_LinearStringEqualsLiteral(nameStr, "NodeFilter")) {
NodeFilter = true;
} else if (JS_LinearStringEqualsLiteral(nameStr, "PathUtils")) {
PathUtils = true;
} else if (JS_LinearStringEqualsLiteral(nameStr, "Performance")) {
Performance = true;
} else if (JS_LinearStringEqualsLiteral(nameStr, "PromiseDebugging")) {
Expand Down Expand Up @@ -1052,6 +1058,10 @@ bool xpc::GlobalProperties::Define(JSContext* cx, JS::HandleObject obj) {
return false;
}

if (IOUtils && !dom::IOUtils_Binding::GetConstructorObject(cx)) {
return false;
}

if (InspectorUtils && !dom::InspectorUtils_Binding::GetConstructorObject(cx))
return false;

Expand All @@ -1068,6 +1078,10 @@ bool xpc::GlobalProperties::Define(JSContext* cx, JS::HandleObject obj) {
return false;
}

if (PathUtils && !dom::PathUtils_Binding::GetConstructorObject(cx)) {
return false;
}

if (Performance && !dom::Performance_Binding::GetConstructorObject(cx)) {
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions js/xpconnect/src/xpcprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2243,10 +2243,12 @@ struct GlobalProperties {
bool FileReader : 1;
bool FormData : 1;
bool Headers : 1;
bool IOUtils : 1;
bool InspectorUtils : 1;
bool MessageChannel : 1;
bool Node : 1;
bool NodeFilter : 1;
bool PathUtils : 1;
bool Performance : 1;
bool PromiseDebugging : 1;
bool Range : 1;
Expand Down

0 comments on commit 46c935e

Please sign in to comment.