chrome.extension.getViews() doesn't seem to be returning a View when specifying a valid tabId
Reported by
royx...@gmail.com,
May 21 2018
|
|||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Steps to reproduce the problem:
1. Install the attached sample extension or create an extension that has a popup with the following JavaScript code that tests chrome.extension.getViews() using both tabId and windowId:
document.addEventListener("DOMContentLoaded", function() {
chrome.tabs.query({active: true, lastFocusedWindow: true}, function (result) {
var activeTab = result && result[0] ? result[0] : undefined;
if (activeTab) {
console.log("Found the active tab:");
console.log(activeTab);
console.log("Getting the View using tabId:" + activeTab.id);
console.log(chrome.extension.getViews({"type": "popup", "tabId": activeTab.id})); // Returns an empty array of Views
console.log("Getting the View using windowId:" + activeTab.windowId);
console.log(chrome.extension.getViews({"type": "popup", "windowId": activeTab.windowId})); // Returns an array with the Popup View
} else {
console.log("No active tab was found");
}
});
});
2. Inspect the Popup Window and observe what the console is outputting in the above code
What is the expected behavior?
An array with the Popup View is returned
What went wrong?
An empty array with no Views is returned
WebStore page:
Did this work before? N/A
Chrome version: 66.0.3359.181 Channel: stable
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
This is in reference to the following method:
https://developer.chrome.com/extensions/extension#method-getViews
I may be misunderstanding how the method is supposed to work when you specify the tabId. I apologize in advance for wasting your time.
,
May 22 2018
Tested the issue on chrome reported version 66.0.3359.181 using Windows-7 with steps mentioned below: 1) Launched chrome reported version and installed extension as provided in comment#0 2) clicked on extension icon, seen popup "Inspect Popup Console", right click on it and clicked on inspect 3) Developer tool opened, clicked on Console tab, please find the attached for observations @Reporter: Please find the attached for your reference and provide your feedback on it which help in further triaging it, if possible provide the screenshot of the issue which help in better understanding. Thanks!
,
May 22 2018
,
May 22 2018
Thank you very much woxxom and viswa.karala! OK to help explain the extension: In the screenshot posted by viswa, first the extension's popup is getting the active tab (woxxom, is there a problem with using chrome.tabs.query in the popup here?). Then it tries to get the Popup View (basically itself) by calling chrome.extension.getViews() using the activeTab's Id, but it only gets an empty array (no view). Then to make sure there really is a Popup View, it calls chrome.extension.getViews() again using the activeTab's windowID, and it successfully returns an array with the popup view. What I wasn't understanding is why when specifying the activeTab's ID (this should be the tab where this popup is opened), it is not returning the Popup View, but it is successfully getting the Popup View when the activeTab's windowId is specified. Is the activeTab being retrieved not the same tab where this Popup View exists? I was trying to use similar code in the background of an extension to close a specific tab's popup (if it was opened), but I could not get it working and had to resort to closing all the popup views returned from the window. I have replaced the code with another approach, so all is well now. I apologize once again for wasting your time. Please feel free to close this as Not a Bug. Thank you all very much once again.
,
May 22 2018
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
May 22 2018
A browserAction popup is a separate window technically, it doesn't run "inside" any tabs, which is why specifying a tab ID doesn't produce any results in this case.
,
May 23 2018
As per comment#4 from the reporter, closing the issue and marking it as won't fix. Thanks! |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by woxxom@gmail.com
, May 21 2018