Pauan / tab-organizer

Google Chrome Extension that makes it easier to manage many tabs!
MIT License
67 stars 8 forks source link

Options page and popup can become out of sync. #34

Closed Pauan closed 9 years ago

Pauan commented 9 years ago

Originally reported on Google Code with ID 34

What steps will reproduce the problem?
1. Open up the popup.
2. Open up the options page.
3. Select the "Theme" section in the options page.
4. Change the window theme, and note that both update properly.
5. Refresh the popup.
6. Change the window theme.

What is the expected output? What do you see instead?
The options page and popup should remain in sync. Instead, the popup updates correctly,
but the options page stops updating.

If you refresh/reload the options page, it will now correctly update, but then the
popup stops updating!

Please provide any additional information below.
This only happens when the 1st page is reloaded.

For instance:

If you open the popup first, then reload the options page, they stay in sync.
If you open the popup first, then reload the popup, things are broken.

If you open the options page first, then reload the popup, they stay in sync.
If you open the options page first, then reload the options page, things are broken.

Reported by pcxunlimited on 2010-09-12 03:43:40

Pauan commented 9 years ago
I'll try to fix this.

Reported by pcxunlimited on 2010-09-12 03:47:18

Pauan commented 9 years ago

Reported by pcxunlimited on 2010-09-12 05:16:49

Pauan commented 9 years ago
Okay, I found the cause. Every time a page loads "Options.js", it will overwrite "Options.addEventListener".

So, for instance, let's say you load up "window.html". It has now overwritten "Options.addEventListener"
to point to itself. Now, you load up "options.html", and it rewrites "Options.addEventListener"
to point to itself.

At this point, all events are being routed into a single "Options.addEventListener"
function, which means whenever a page is unloaded, poof everything disappears.

The problem is, every page is synced up with the Options function, and we're overwriting
properties on said function, which causes the property to change on every page!

I found a solution, but it involves creating a separate namespace for every URL, then
dynamically returning a function depending on the URL. This works, but I'm not sure
about the performance impact.

Reported by pcxunlimited on 2010-09-12 11:41:29

Pauan commented 9 years ago
This issue was updated by revision d78ce61dd3.

Reported by pcxunlimited on 2010-09-12 11:41:58

Pauan commented 9 years ago
The new solution used in revision 557dc15283 should work better. Either way, it looks
like this works properly now.

Reported by pcxunlimited on 2010-09-12 16:05:41

Pauan commented 9 years ago

Reported by pcxunlimited on 2010-09-16 21:15:16

Pauan commented 9 years ago

Reported by pcxunlimited on 2010-11-21 18:49:48

Pauan commented 9 years ago

Reported by pcxunlimited on 2012-08-27 21:56:56

Pauan commented 9 years ago

Reported by pcxunlimited on 2012-08-27 23:44:47