Comments (3)
Perhaps this is because chrome code can still access [ChromeOnly] globals in a content document. Still, if it's the content that is accessing the chrome-only global, I wouldn't expect Gecko to instantiate it.
In any case, I've landed 62dc6fa in #60 to work around the problem, but I'm leaving this open for the real fix.
from positron.
The global also gets initialized for the hidden window, although that's less of a problem, since we can control what the hidden window references and ensure that it doesn't reference the global (whereas content windows are beyond our control, and at least https://github.com/ actually does reference it).
Currently, this isn't a problem, as we've given the BrowserWindow document the system principal, and we've moved the component to the JavaScript-global-privileged-property
category, so it only gets initialized for chrome windows. But I'm looking into removing the hack that gives the BrowserWindow document the system principal, at which point we'll need to make the component a JavaScript-global-property
again, and then this'll become an issue again.
Probably the correct fix is to restrict the WebIDL binding specifically to BrowserWindow documents using the Func extended attribute. We may have to reimplement the binding natively in that case, as I don't think Func is implementable in JS. But perhaps we can get away with implementing Func natively and the rest of the binding in JS.
from positron.
This is a WIP hack to work around this issue. Unsure if it still works, as it's a few months old. (I had it lying around in my local clone and want to make sure I don't lose it.)
diff --git a/positron/components/Process.js b/positron/components/Process.js
index 14a5544..5d94b1d 100644
--- a/positron/components/Process.js
+++ b/positron/components/Process.js
@@ -35,16 +35,31 @@ Process.prototype = {
/**
* Initialize the global `process` property. See the code comment
* https://dxr.mozilla.org/mozilla-central/rev/21bf1af/toolkit/mozapps/extensions/amInstallTrigger.js#124-133
* for an explanation of the behavior of this method.
*/
init: function(window) {
this._contentWindow = window;
+ // The binding appears to get initialized even for a document in a content
+ // docshell, even though it's marked [ChromeOnly]. Hack around that.
+ // TODO: https://github.com/mozilla/positron/issues/64
+ const docShellType = window.QueryInterface(Ci.nsIInterfaceRequestor).
+ getInterface(Ci.nsIWebNavigation).
+ QueryInterface(Ci.nsIDocShell).itemType;
+ if (docShellType !== Ci.nsIDocShellTreeItem.typeChrome) {
+ this._processGlobal = new Proxy({}, {
+ get: function(target, name) {
+ window.console.error("'process' not defined in hidden window");
+ }
+ });
+ return window.processImpl._create(window, this);
+ }
+
// The WebIDL binding applies to the hidden window too, but we don't want
// to initialize the Electron environment for that window, so return early
// if we've been called to initialize `process` for that window.
//
// TODO: restrict the WebIDL binding to windows opened by the Electron app
// using the Func extended attribute
// <https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings#Func>.
//
from positron.
Related Issues (20)
- Git complains about user's identity in task run
- console.log logs to terminal but not console window HOT 5
- Resources for beginners? (very interested) HOT 10
- determine correct way to express SpiderNode dependency on static:js
- determine correct way to express libxul dependency on SpiderNode on Linux
- determine correct way to specify positron/app/spidernode subconfigure dir
- node-integration builds busted on Linux because static lib locations differ
- Fix shutdown memory leak
- Add lock for isolate in NodeBindings
- Emit loaded event from node bindings
- Move node bindings and node loader out of webidl folder HOT 5
- MOZ_CRASH(Accessing the Subject Principal without an AutoJSAPI on the stack is forbidden) at /Users/myk/Projects/positron/dom/base/nsContentUtils.cpp:2760 HOT 3
- cp: cannot create regular file '…libzlib.a': File exists
- Call add-on sdk functionality from Positron HOT 12
- synchronously retrieve back/forward status of mozbrowser HOT 3
- figure out if/when to set WebViewImpl.attached/elementAttached
- benchmark Positron perf and compare it to Electron HOT 1
- GuestWebContentsPrototype.getURL fails because contentDocument is null
- loading renderer modules in single sandbox throws "TypeError: 'get location' called on an object that does not implement interface Window."
- Find or implement an event similar to blink's NavigationEntryCommitted
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from positron.