New issue
Advanced search Search tips

Issue 673662 link

Starred by 1 user

Issue metadata

Status: Archived
Owner: ----
Closed: Feb 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug-Regression



Sign in to add a comment

Unable to access Global variables in chrome extension through chrome.tabs.executescript in Chrome version 55.0.2883.75

Reported by rakeshad...@gmail.com, Dec 13 2016

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36

Steps to reproduce the problem:
1.Store any value in global variable of chrome extension javascript 
2.Access it in the method  "chrome.tabs.executescript"
3.You cant access it. 

What is the expected behavior?
You should be able to access global variables in the same javascript defined outside, into "chrome.tabs.executescript" method.

My Code Below :

Step 1 :

chrome.extension.onRequest.addListener(
    function (request, sender, sendResponse) {
        parser = new DOMParser();
        htmlDoc = parser.parseFromString(request.content, "text/html");

        //outputJson is a global variable which is Populated here
        outputJson = parseMyPage(outputJson, htmlDoc);

    });

Step 2:

chrome.tabs.getSelected(null, function (tab) {
    // Now inject a script onto the page
    chrome.tabs.executeScript(tab.id,{
        code: "chrome.extension.sendRequest({content: document.body.innerHTML}, function(response) { console.log('success'); });"
    }, function () {

       //my code to access global variables
if (outputJson && null != outputJson) {
    // other stuff
}

    });
});

What went wrong?
The value in the variable is empty when I try to access it inside "chrome.tabs.executescript"

Did this work before? Yes Chrome Version 54

Does this work in other browsers? N/A

Chrome version: 55.0.2883.75  Channel: n/a
OS Version: 14.04
Flash Version: Shockwave Flash 23.0.0.207

It was working fine untill Chrome version 54. When I updated to version 55, it doesnt work.
 
Labels: M-55 prestable-55.0.2883.75
Hi there,

Sorry, I didnt get what does the reply "Labels: M-55 prestable-55.0.2883.75"
means actually ??

Can you please elaborate ?
Cc: kkaluri@chromium.org
Labels: Needs-Feedback
 rakeshadak137@g In order to triage this issue could you please provide the sample extension file and the steps to reproduce the issue.

Thank you... 
Components: -Blink>JavaScript Platform>Extensions
Project Member

Comment 5 by sheriffbot@chromium.org, Feb 12 2018

Status: Archived (was: Unconfirmed)
Issue has not been modified or commented on in the last 365 days, please re-open or file a new bug if this is still an issue.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Sign in to add a comment