New issue
Advanced search Search tips

Issue 845202 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: May 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

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.
 
sample.zip
3.2 KB Download

Comment 1 by woxxom@gmail.com, May 21 2018

The observed behavior is correct and matches the documentation.
The browserAction popup is not a tab, hence it's not returned by chrome.tabs.query.

Labels: Needs-Feedback Triaged-ET
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!
845202.PNG
85.4 KB View Download
Labels: Needs-Triage-M66

Comment 4 by royx...@gmail.com, 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.
Project Member

Comment 5 by sheriffbot@chromium.org, May 22 2018

Cc: viswa.karala@chromium.org
Labels: -Needs-Feedback
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

Comment 6 by woxxom@gmail.com, 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.
Status: WontFix (was: Unconfirmed)
As per comment#4 from the reporter, closing the issue and marking it as won't fix.

Thanks!

Sign in to add a comment