Chrome extension tests

I'm trying to access __data__ attributes of SVG elements on a page. If I paste my script into the console, it's fine and I can access them OK.

But if I inject the same script with chrome.tags.executeScript(...), then they're all undefined. (I've tried all the 'runAt' options).

Here's a small sample project that demonstrates this.

Instructions

  • Install the local Chrome extension from the extension-problem directory. Here's how.
  • Go to the index page (it's hosted here), click the extension and click the revealed button.
  • Check the console. It should output the data (200 and 400) but instead it is undefined.

Update: It's solved now. See the extension-solution directory. Thanks to wOxxOm and apsillers over on Stack Overflow!