Closed Bug 1299408 Opened 8 years ago Closed 8 years ago

can't get TabID from loadContext

Categories

(Developer Documentation Graveyard :: Add-ons, defect)

All
Windows 10
defect
Not set
normal

Tracking

(e10s+)

RESOLVED FIXED
Tracking Status
e10s + ---

People

(Reporter: phanthai12, Unassigned)

References

()

Details

(Keywords: dev-doc-complete, Whiteboard: triaged)

Attachments

(1 file)

3.53 KB, application/javascript
Details
Attached file index.js
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Steps to reproduce: Here is My code: Cu.import('resource://gre/modules/Services.jsm'); var httpObs = { observe: function (aSubject, aTopic, aData) { if (aTopic == 'http-on-modify-request') { /*start - do not edit here*/ var oHttp = aSubject.QueryInterface(Ci.nsIHttpChannel); //i used nsIHttpChannel but i guess you can use nsIChannel, im not sure why though var interfaceRequestor = oHttp.notificationCallbacks.QueryInterface(Ci.nsIInterfaceRequestor); //var DOMWindow = interfaceRequestor.getInterface(Ci.nsIDOMWindow); //not to be done anymore because: https://developer.mozilla.org/en-US/docs/Updating_extensions_for_Firefox_3.5#Getting_a_load_context_from_a_request //instead do the loadContext stuff below var loadContext; try { loadContext = aSubject.QueryInterface(Ci.nsIChannel) // aSubject is equivalent to aSubject from observe .notificationCallbacks .getInterface(Ci.nsILoadContext); } catch (ex) { try { loadContext = aSubject.loadGroup.notificationCallbacks .getInterface(Ci.nsILoadContext); } catch (ex) { loadContext = null; } } /*end do not edit here*/ /*start - do all your edits below here*/ var url = oHttp.URI.spec; //can get url without needing loadContext if(loadContext){ var window = loadContext.associatedWindow; var utab = utabs.getTabForContentWindow(window); console.log(utabs.getTabId(utab)); } } } }; Services.obs.addObserver(httpObs, 'http-on-modify-request', false); Actual results: console.log: test: -5-2 console.log: test: -5-2 console.log: test: -5-2 console.log: test: -5-2 console.log: test: -5-2 console.log: test: -5-2 console.log: test: -5-2 console.log: test: -5-2 console.log: test: -5-2 console.log: test: -5-2 console.log: test: -5-2 console.log: test: -5-2 console.log: test: -5-2 Expected results: console.log: test: -5-1 console.log: .... console.log: test: -5-1 console.log: test: -5-2 console.log: .... console.log: test: -5-2 console.log: test: -5-3 console.log: .... console.log: test: -5-3
tracking-e10s: --- → ?
OS: Unspecified → Windows 10
Hardware: Unspecified → All
Component: Untriaged → Extension Compatibility
I think there should be a way to help us get tabID without nsIDOMWindow. Can we create a different channel (eg nsITab) used to connect via methods QueryInterface.
looks like this needs to be updated on mdn
Keywords: dev-doc-needed
That page should probably just be archived.
Component: Extension Compatibility → Add-ons
Product: Firefox → Developer Documentation
Version: 51 Branch → unspecified
Whiteboard: triaged
Has not been corrected in version 52
Flags: needinfo?(wbamberg)
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
(In reply to Will Bamberg [:wbamberg] from comment #6) > -> https://developer.mozilla.org/en-US/docs/Archive/Add-ons/Tabbed_browser No way to get tabID from HTTPChannel?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: