chrome.runtime missing properties in manifest v3

Viewed 639

I am trying to migrate my browser extension to manifest version 3 but I am not able to access some properties from chrome.runtime in my service_worker. Code explains more than words I guess.

My background.js file:

function call() {
    console.log({ runtime: chrome.runtime })
    chrome.runtime.getPackageDirectoryEntry(() => null)
}

// putting it to timeout otherwise I couldn't access the logs page
setTimeout(() => {
    call()
}, 0)

My manifest:

{
    "manifest_version": 3,
    "name": "Test",
    "version": "0.0.0",
    "background": {
        "service_worker": "background.js"
    }
}

When I open service worker page I can see

Uncaught TypeError: chrome.runtime.getPackageDirectoryEntry is not a function

The same code works with v2:

{
    "manifest_version": 2,
    "name": "Test",
    "version": "0.0.0",
    "background": {
        "scripts": ["backgroud.js"]
    }
}

The method I am trying to use is documented here but it is clearly missing in the runtime object (with plenty of others...)

0 Answers
Related