executeScript does not correctly return results in its callback

Confirmed Issue #8504764 • Assigned to Scott S.


Aug 16, 2016
This issue is public.
Reported by 4 people

Sign in to watch or report this issue.

Steps to reproduce

Background script:

browser.browserAction.onClicked.addListener(function() {
    browser.tabs.query({ active: true, lastFocusedWindow: true }, function(tabs) {
        var tab = tabs[0];
        browser.tabs.executeScript(tab.id, {code: "var x = 10; x"}, function(result) {

This results in an empty alert in Edge, but does not in Chrome


0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Sermet I.”

      Changed Assigned To from “Sermet I.” to “Scott S.”

      Changed Status to “Confirmed”

    • Hi,

      is there any plan, when this problem will be fixed?


      Svatopluk Ordelt

    • This is an important API to support properly since, among other reasons, in Chrome, you can’t use sendMessage to broadcast a message to all frames of a tab and get answers from all of them - you get whatever answer arrives first. (note: this applies to sendResponse - you can of course call runtime.sendMessage from the content scripts, but then you have to implement your own message tracking logic)
      In contrast, executeScript aggregates answers, which makes it useful as a workaround. I realize this bug is not about frame support, but it will be important on the way.

    • more compact repro:

      chrome.tabs.query({}, tabs =>
              {code: '"foo"'},
              results => console.log("results", results)))

      should log: results ["foo"]

      logs: results undefined

    You need to sign in to your Microsoft account to add a comment.

    Sign in