Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

window.onload #21

Open
jsocol opened this issue Dec 10, 2012 · 2 comments
Open

window.onload #21

jsocol opened this issue Dec 10, 2012 · 2 comments

Comments

@jsocol
Copy link

jsocol commented Dec 10, 2012

Chrome's version (at least the port to Windows) runs well before the window load event fires. This, as with all pageMods from the Add-on SDK, runs after.

(NB: I prefer after, since I can just manage the DOM as it already exists, but, meh.)

It's worth considering finding a way to make these compatible. The issue I ran into is that for Chrome, I need to add an onload handler, and for Firefox, load has already fired before this runs, so adding a handler doesn't work.

If I'm the only one to hit this, it's probably the chrome dotjs Windows port's fault.

@rlr
Copy link
Owner

rlr commented Dec 20, 2012

@canuckistani any ideas for this?

I wonder if there is a sneaky way to look at the window load event handlers before and after we inject the scripts and directly call the new ones.

@jeffgca
Copy link
Contributor

jeffgca commented Dec 20, 2012

Here's the SDK bug:

https://bugzilla.mozilla.org/show_bug.cgi?id=787063

Basically, no. Also, and I freel yadmit this is an implementation detail, window.onload if we supported it is dangerously misleading in a content script. Content scripts are in their own sandbox so window is actually a proxy. If we let a content script set the real window.onload this would do two things:

  1. override whatever was set there ( although real web hackers don't use window.onload anyway )
  2. open up a channel between the real window and the content script, possible creating a security problem.

Dunno, IMO window.onload use causes the death of many many kittens at the hands of a ruthless and bloodthirsty old-testament-type god. I can't recommend it.

We could play around with using contentScriptWhen: 'start', for example, but I don't think that will do what we want most of the time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants