Closed Bug 855238 Opened 12 years ago Closed 12 years ago

Addons SDK lacks the means to listen to page loads from cached pages

Categories

(Add-on SDK Graveyard :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 671305

People

(Reporter: mgoodwin, Unassigned)

Details

The current techniques for monitoring page loads (e.g. tabs.on('ready',somefunc) do not work for cached pages. It would be useful if an API could be added to allow this. Something similar to the pageshow event which allows the receiver to determine wheher the loaded document is persited would be idea. Needinfo kailas if you require more information on API use cases.
API like following could be useful to differentiate between normal page load and page load from cache. tabs.on('pageshow', function(evtTab) { if (evtTab.persisted) console.log ("page loaded from cache"); });
(In reply to Kailas from comment #1) > API like following could be useful to differentiate between normal page load > and page load from cache. > > tabs.on('pageshow', function(evtTab) { > if (evtTab.persisted) console.log ("page loaded from cache"); > > }); Identification of page load from cache is required in userCSP add-on. When page is loaded from cache we need to reflect the currently visible sites in the add-on. In addition, we also need to access HTTP header (Content-Security-Policy) which will be available in browser cache if website has specified CSP policy. Therefore, detection of web page load from cache will help.
I think it is a reasonable request to add pageshow/pagehide events to the tabs high level API. But it won't necessary fit all your needs, especially accessing http header. Accessing http headers seems like a lower level need. So I'd imagine you want to access low level tab at some point. We are in middle of a rewriting of low level tabs API and I haven't been able to found any usefull helper to listen to all tabs open in order to then listen to pageshow/pagehide... It might be easier to use the high level API, with this new pageshow/hide feature and also introduce a way to get low level tab from high level one gozala, your thoughts? I think that it would be easy to expose pageshow/hide. It should also be easy to expose low level tab without having to wait for the full rewrite, isn't?
Component: API → General
Flags: needinfo?(rFobic)
Product: addons.mozilla.org → Add-on SDK
Kailas, I don't know if you have seen my irc message, but here is a code snippet to listen to any location change happening in current browser window. If you feel confident about using low level stuff, you might give it a look: http://pastebin.mozilla.org/2251020
Ochameau: Thank you very much for your help! It worked smoothly. To work around the problem of detection of web page loads from cache, I register event listener on Back/Forward browser buttons. When event listener for Back/Forward button fires, I register onChange event listener on Location bar and unregister onChange event listener inside onChange event listener. Thanks!
Flags: needinfo?(rFobic)
I think Jordan's work in 671305 should help here.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
Needinfo is no longer relevant.
Flags: needinfo?(rFobic)
You need to log in before you can comment on or make changes to this bug.