Evgeny
Evgeny

Reputation: 26

API Call 'tabs.captureVisibleTab' is not supported in Edge

I'm using Edge on Windows 10 v1703, build 15063.296. The documentation (https://learn.microsoft.com/en-us/microsoft-edge/extensions/api-support/supported-apis) states, that the API tabs.captureVisibleTab is available.

But when I use it in the background script, I'm getting the following error:

API Call 'tabs.captureVisibleTab' is not supported in Edge.

The code is:

browser.tabs.captureVisibleTab(currentTab.windowId, {format: "png"}, function (data) {});

Am I missing something?

UPDATE:

this is my manifest file (ported from Chrome):

{
"author": "Evgeny Suslikov",
"background": {
    "page": "background.html",
    "persistent": true
},
"browser_action": {
    "default_icon": {
        "19": "images/sss_19.png"
    },
    "default_title": "FireShot - Capture page",
    "default_popup": "fsPopup.html"
},
"commands": {
    "last-used-action": {
        "suggested_key": {
            "default": "Ctrl+Shift+Y",
            "mac": "Command+Shift+Y"
        },
        "description": "__MSG_options_label_last_action_hotkey__"
    }
},
"default_locale": "en",
"description": "__MSG_application_description__",
"icons": {
    "16": "images/sss_16.png",
    "32": "images/sss_32.png",
    "48": "images/sss_48.png",
    "128": "images/sss_128.png"
},
"Key": "B5SSrXXpDZAoT8SQ4vAzNeTQ1tBC2Z24nx+hHZXfykmVYfMy5aOwPkf0Hbt7SXlKbprwV0GwrYgCwIDAQAB",
"manifest_version": 2,
"name": "__MSG_application_title__",
"offline_enabled": true,
"optional_permissions": [
    "tabs",
    "<all_urls>",
    "downloads"
],
"options_page": "fsOptions.html",
"permissions": [
    "activeTab",
    "tabs",
    "contextMenus",
    "nativeMessaging"
],
"short_name": "FireShot",
"version": "0.98.92",
"web_accessible_resources": [
    "images/*.gif"
],
"-ms-preload": {
    "backgroundScript": "backgroundScriptsAPIBridge.js",
    "contentScript": "contentScriptsAPIBridge.js"
},

"content_scripts": [{
    "matches": ["<all_urls>"],
    "js": ["scripts/fsUtils.js", "scripts/fsSelection.js", "scripts/fsLinks.js", "scripts/fsContent.js"]
}]
}

In my fsBackground.js page I do the call:

     browser.tabs.captureVisibleTab(windowId, {format: "png"}, function (data) {});

I get the following error: click to see screenshot...

Upvotes: 0

Views: 343

Answers (1)

Maluen
Maluen

Reputation: 1841

That function is supported starting from Edge 15. On previous versions it was still unsupported, even though the documentation said differently.

Make sure to download the latest version of Microsoft Edge Extension Toolkit and to regenerate the bridge files with it.

You can look at the generated backgroundScriptsAPIBridge.js file to see what's changed.

Previous versions (unsupported):

captureVisibleTab(windowId, options, callback) {
    bridgeLog.LogUnavailbleApi("tabs.captureVisibleTab");
}

New version (supported):

captureVisibleTab(windowId, options, callback) {
    bridgeLog.DoActionAndLog(() => {
        myBrowser.tabs.captureVisibleTab.apply(null, arguments);
    }, "tabs.captureVisibleTab");
}

Upvotes: 1

Related Questions