Getting cookies from a devtools panel

I’m having trouble creating a new devtools panel and having it list the cookies in the page. I have managed to show a panel, pretty much copying the devtools-panel example, and I have managed to list cookies, by copying the list-cookies example. But, if I try to use the browser.cookies api from a devtool panel, I get undefined. What do I need to do to access the extension api from a devtool panel?

See the Working with content scripts section. I think the same applies to all/most other browser.* APIs.