-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Firefox add-ons execution environment #44
Comments
I fixed cross-origin access only about window.history.state. Is there another illegal access?
If you actually get that error, can you also show me it and its call stack? |
OK, it should be fixed at v3.31.1. Can you confirm it? |
It's not :( The issue occurs in
pjax-api/src/layer/data/store/state.ts Lines 30 to 40 in c22b440
|
Sorry, I missed later commits in which you fixed savePosition. But the issue does still exist after I updated |
OK, I'll remove Object.freeze. |
Fixed at v3.31.2. |
It works! Thank you so much! Now I can release next version of Gitako and users will have better user experiences! If you use GitHub frequently, please give a try :P |
Hi @falsandtru
I'm the maintainer of a GitHub file tree extension, Gitako, which depends on PJAX lib to work properly. Thank you for implementing this great new generation of PJAX lib, I found it working much better than the one I was using before! However, while it worked very well in Chrome, I encountered an cross-origin issue when trying to use it in Firefox -
Not allowed to define cross-origin object as property on [Object] or [Array] XrayWrapper
, which crashes my extension then.What I've done
I've tried to fix it by myself, but couldn't figure it out after many hours of work. So I decided to ask for your help.
The reason it happen is, according to MDN, add-on for Firefox runs in a context other than the context that webpage js runs in.
So that some operations happened inside
pjax-api
(e.g. assigning variables to properties ofwindow.location
) triggered cross-origin issue becausewindow
is not from add-ons context.But my add-on used https://github.com/MoOx/pjax and it worked well even in Firefox. So I think PJAX mechanism is not technically unavailable in Firefox. What we need is few minor changes in
pjax-api
, like switching from passing objects to assigning object properties specifically to prevent passing objects cross-origin.How to reproduce it
If you'd like to help (it would be very kind of you!), please continue reading about how to reproduce the issue on your local environment.
In case you might not be familiar about browser extension development, I've setup a project for you - https://github.com/EnixCoda/pjax-api-firefox-demo
Please clone it and install dependencies with yarn.
Run
yarn watch
to emit files for debug and then runyarn debug-firefox
in another terminal session to debug in Firefox. You should see a Firefox window pop out.Go visit some webpage. I'd suggest https://nobody.github.io as it'll take you to a clean 404 page which has no much JS files.
Open dev console and you should see
App is running!
like below, which indicates the app works by default.Then go to
src/content_script.ts
, uncomment those commented lines. Nowpjax-api
is imported. Refresh browser page. TheApp is running!
log won't appear now. Because app crashed in importingpjax-api
, before it executed to where the log statement is.Now go to
Debugger
tab, checkPause on exceptions
andPause on caught exceptions
underbreakpoint
pane. Refresh page again. You should see exactly what I showed you in the first screenshot -Not allowed to define cross-origin object as property on [Object] or [Array] XrayWrapper
.Then you should be able to see what is going wrong.
I'd be very grateful if you either take a look into the issue or guide me about how to fix it myself. Thank you very much!
The text was updated successfully, but these errors were encountered: