page-mod content scripts not triggering appropriately

RESOLVED INVALID

Status

Add-on SDK
General
P1
normal
RESOLVED INVALID
7 years ago
7 years ago

People

(Reporter: Steve Sobel, Assigned: ochameau)

Tracking

unspecified
x86
Windows Vista

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

235.11 KB, application/octet-stream
Details
(Reporter)

Description

7 years ago
User-Agent:       Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Build Identifier: Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1

I may just be misunderstanding how Jetpack is supposed to work, but I can't find documentation that clarifies it.  My understanding is that if I have a page-mod that includes *.foo.com - then my contentScriptFile should be executed every time I visit any page on *.foo.com... 

Assuming that to be correct, I think there is a problem... 

I'm trying to write an addon that makes DOM modifications (amongst other things) to reddit.com, and it runs properly the first time I visit any reddit.com page.  However, clicking a link to another reddit.com page results in nothing - the content script is not executed.

To generalize even further, I've made a very simple test case that seems to show a problem.  I've made my include match *, and all my contentScriptFile does is console.log(location.href) -- like so:

lib/main.js:

// Import the APIs we need.
var pageMod = require("page-mod");
var self = require("self");
pageMod.PageMod({
  include: ["*"],
  contentScriptWhen: 'ready',
  contentScriptFile: self.data.url('test.js')
});



data/test.js:
console.log(location.href);


If you do this, and then visit http://www.reddit.com/ you'll see two log entries:

- http://www.reddit.com
- http://www.redditmedia.com/ads/

Now click any link from reddit.com to another page on reddit.com.. in this case I'll click a comments link.. I see the following URL in my console.log:

- http://www.redditmedia.com/ads/r/pics

Note that there is no presence of the URL I'm actually visiting, which is http://www.reddit.com/r/pics/comments/hkydf/lord_of_the_rings_revision/ - it looks like the script never executed on that page...


Now we try another site - http://slickdeals.net -- oddly, http://slickdeals.net never shows up in console.log - not even the first time I visit!  Instead, the only things showing up in console.log are long URLs that clearly seem to be from iFrames / ad units:

info: http://204.93.181.78/sd/dmsd.html
info: http://pubads.g.doubleclick.net/gampad/ads?[parameters removed for brevity]
info: http://static.ak.fbcdn.net/connect/xd_proxy.php?[parameters removed for brevity]
info: http://pubads.g.doubleclick.net/gampad/ads?[parameters removed for brevity]
info: http://pubads.g.doubleclick.net/gampad/ads?[parameters removed for brevity]
info: http://pubads.g.doubleclick.net/gampad/ads?[parameters removed for brevity]




Reproducible: Always

Steps to Reproduce:
1. Create an empty addon with the following code:

lib/main.js:

// Import the APIs we need.
var pageMod = require("page-mod");
var self = require("self");
pageMod.PageMod({
  include: ["*"],
  contentScriptWhen: 'ready',
  contentScriptFile: self.data.url('test.js')
});



data/test.js:
console.log(location.href);



2. visit http://www.reddit.com/ you'll see two log entries from the console.log statement in test.js:

- http://www.reddit.com
- http://www.redditmedia.com/ads/

Now, click any link on reddit.com that leads to another page on reddit.com


Actual Results:  
That page won't ever see test.js executed - thus it won't show up in console.log - only the iframe'd ad page will, for example: http://www.redditmedia.com/ads/r/pics

test.js doesn't seem to execute when I think it should...



Expected Results:  
My expected result would be to see test.js get executed on the link I clicked -- in this case: http://www.reddit.com/r/pics/comments/hkydf/lord_of_the_rings_revision/
Alex: can you take a look at this?
Priority: -- → P1
Target Milestone: --- → 1.0
Blocks: 660286
(Assignee)

Comment 2

7 years ago
Steve: I'm not able to reproduce the behavior you are describing here. 
Not on current master nor on 1.0b5 version.
What SDK version are you using?
If you are using 1.0b5, may you send us an example package?
(Reporter)

Comment 3

7 years ago
Alexandre:

Thanks for the reply - sure, I can send you an example package.  what is the best way for me to deliver that to you?
(In reply to comment #3)
> Alexandre:
> 
> Thanks for the reply - sure, I can send you an example package.  what is the
> best way for me to deliver that to you?

Attaching a .xpi file to this bug would probably be the best way: https://bugzilla.mozilla.org/attachment.cgi?bugid=660136&action=enter
(Assignee)

Updated

7 years ago
Assignee: nobody → poirot.alex
(Reporter)

Comment 5

7 years ago
Created attachment 536632 [details]
bug test XPI as requested

Attached is an XPI that exhibits the behavior I have described...
(Assignee)

Comment 6

7 years ago
Thanks for the example.

This is crazy. It still works fine here. I checked on Firefox 4.0.1. So the only difference I'm seeing is that I am on Window7 whereas you are on Window Vista.
But I don't think it's due to OS difference.
I supposed that you tried with cfx run ?
Or may be are you using addon builder ?
I'm asking that because it may be due to another extension that conflict with the SDK.
(Reporter)

Comment 7

7 years ago
Alex,

I actually am on Windows 7 as well, I put in Vista by mistake, probably because I filled the bug out from a different computer...

I am using addon-sdk-1.0b5, and was testing using cfx run

Anything I can do to provide any more detailed information?  Let me know...
(Reporter)

Comment 8

7 years ago
I have some additional information!

It appears I have something weird with my Firefox installation.  I thought I had updated to 4.0.1 because I clicked "Apply Update" when I went to help/about and saw FF 4.0.  I never went back to double check the version as I assumed it was properly updated...

Well, I just checked, and I had 4.0, not 4.0.1 ... this bug appears to go away with 4.0.1.

However, I have an additional oddity going on here that's not really addon related:  When I go to help/about now to confirm I have 4.0.1 - there's still an "Apply Update" button...  Clicking it just closes and reopens firefox. Nothing is applied and the button does not go away.

If I should submit this as a new bug, let me know... I'm not sure what info I can provide that might help get you to why my browser installation is acting this way, though...
I can't reproduce this on the current master, either, on my Ubuntu virtual machine (using cfx run).

Steve, I reduced the testcase down a bit further than you did, completely avoiding a separate contentScriptFile, by using this in main.js:

// Import the APIs we need.
var pageMod = require("page-mod");
pageMod.PageMod({
  include: ["*"],
  contentScriptWhen: 'ready',
  contentScript: "console.log(location.href);"
});


Can you reproduce this problem using that version?

What about if you install just your addon into a new profile? ( http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows )




(For the record, here's what my console log looked like when I tried it:
> cfx run -b /home/kwierso/firefoxb6/firefox
> Using binary at '/home/kwierso/firefoxb6/firefox'.
> Using profile at '/tmp/tmphwAhyr.mozrunner'.

Now that Firefox started, I go to reddit's homepage:
> info: http://www.reddit.com/
> info: http://www.redditmedia.com/ads/

I then click on the "new" link in the site header:
> info: http://www.reddit.com/new/
> info: http://www.redditmedia.com/ads/

Then I clicked on a "comments" link:
> info: http://www.reddit.com/r/pics/comments/hp9e2/harry/
> info: http://www.redditmedia.com/ads/r/pics/

Then I went to slickdeals's homepage:
> info: http://slickdeals.net/
> info: http://204.93.181.78/sd/dmsd.html
> info: http://pubads.g.doubleclick.net[snip]
> info: http://pubads.g.doubleclick.net[snip]
> info: http://pubads.g.doubleclick.net[snip]
> info: http://pubads.g.doubleclick.net[snip]
> info: http://static.ak.fbcdn.net/connect/[snip]
(In reply to comment #8)
> However, I have an additional oddity going on here that's not really addon
> related:  When I go to help/about now to confirm I have 4.0.1 - there's
> still an "Apply Update" button...  Clicking it just closes and reopens
> firefox. Nothing is applied and the button does not go away.
Easiest fix for this that I've found is to just download the 4.0.1 installer and install it over your current version of Firefox, which should clear up the "apply update" thing. Sometimes file permissions get screwy and don't completely clear out updates and stuff.
(Reporter)

Comment 11

7 years ago
Yeah, I've gotten 4.0.1 to install by doing exactly that.

However, I still see an "Apply Update" button even though there probably shouldn't be one...  I'm thinking I may be stuck in a situation where I'll keep having to manually update FF from here on out.. not the end of the world I suppose..
See also: http://support.mozilla.com/en-US/kb/Updates%20reported%20when%20running%20newest%20version
If you need more help, you can hit me up on IRC in the #jetpack channel.
(In reply to comment #8)
> I have some additional information!
> 
> It appears I have something weird with my Firefox installation.  I thought I
> had updated to 4.0.1 because I clicked "Apply Update" when I went to
> help/about and saw FF 4.0.  I never went back to double check the version as
> I assumed it was properly updated...
> 
> Well, I just checked, and I had 4.0, not 4.0.1 ... this bug appears to go
> away with 4.0.1.
> 
> However, I have an additional oddity going on here that's not really addon
> related:  When I go to help/about now to confirm I have 4.0.1 - there's
> still an "Apply Update" button...  Clicking it just closes and reopens
> firefox. Nothing is applied and the button does not go away.
> 
> If I should submit this as a new bug, let me know... I'm not sure what info
> I can provide that might help get you to why my browser installation is
> acting this way, though...

Hi Steve,

I think it would be best to create a separate bug for that under the firefox product: https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox

Also I'll close this bug since it seems to work for everyone now!

Thanks for the report.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.