rlr / dotjs-addon

[unmaintained] ~/.js for Firefox
BSD 3-Clause "New" or "Revised" License
144 stars 17 forks source link

Page opened in background tab, some code runs for active tab #9

Closed mikavilpas closed 12 years ago

mikavilpas commented 12 years ago

I have some code that reworks a site, and it works fine when browsing to a page in the active tab. However, when opening tabs as background tabs (e.g. right click -> Open tab in background tab), the code is not run successfully for that page.

Here's an example:

document.title = document.title.replace("foo", "bar")

It seems to me that at least some code is run for the background tab. That's why I'm wondering if I'm calling the title changing function in a wrong way. I think I need some way to access the background tab, but all my other code (jQuery) works without one.

mikavilpas commented 12 years ago

Here's an example with which I am able to replicate the error:

github.com.js

// swap github logo with trollface
$('#header .logo img')            
  .css('width', '100px')          
  .css('margin-top', '-15px')     
  .attr('src', '//bit.ly/ghD24e') 

document.title = "problem, unrelated page?"           

Save the file with the filename above the code, and reload a github page. The title on that page will change to the one in the code. Now open up another page, say google.com, in a new tab. Then reload the github tab. The title of google.com will be changed instead. Also note that the github logo is changed to trollface on the correct page.

mikavilpas commented 12 years ago

I updated firefox. The issue is also active in

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0.1) Gecko/20100101 Firefox/6.0.1

djl commented 12 years ago

Looks like this was caused by e7ce13d9ec5fc00ed8a1c95eb7eb5a755a1081b7. Rolling that back and packaging with the latest version of SDK fixes the issue (maybe mozilla/addon-sdk#167 was part of the issue?)

As far as I can tell, the workaround in e7ce13d9ec5fc00ed8a1c95eb7eb5a755a1081b7 is no longer needed so it should be removed anyway.

rlr commented 12 years ago

If this is still happening, please reopen.