Reputation: 1327
Is it possible, from within the "http-on-modify-request" event, to identify which requests are coming from a PageWorker object, as opposed to those coming from visible tabs/windows?
Note: Because of redirects and subresources, the URL here is NOT the same URL as the pageWorkers contentURL property.
require("sdk/system/events").on("http-on-modify-request", function(e) {
var httpChannel = e.subject.QueryInterface(Ci.nsIHttpChannel),
url = httpChannel.URI.spec,
origUrl = httpChannel.originalURI.spec;
...
});
Upvotes: 3
Views: 204
Reputation: 33202
I don't know of any way to actually distinguish page-worker
requests from "regular" ones.
Current, page workers are implemented like this:
<iframe>
in the hiddenWindow
(technically, in sdk/addon/window
, which creates a hidden window in the hiddenWindow
). The hiddenWindow
in mozilla applications is more or less an always-present top-level XUL or HTML window that is simply hidden.iframe
.iframe
.It is possible to identify requests originating from the hidden window and the document within the hidden window.
But identifying if the request or associated document belongs to a page-worker
, let alone which page-worker
instance, doesn't seem possible, judging from the code. The SDK itself could map the document associated with a request back to a page-worker
, as it keeps some WeakMap
s around to do so, but that is internal stuff you cannot access.
You only can say that a request is not coming from a page-worker when it is not coming from the hiddenWindow
.
Also, keep in mind that there are tons of requests originating neither from a tab
nor page-worker
: Other (XUL) windows, add-ons, js modules and components, etc...
If it a page-worker
created by your add-on that you're interested in: The contentURL
property should reflect the final URI once the page is loaded.
Upvotes: 4