toberndo
toberndo

Reputation: 51

Using sandboxed pages in chrome extensions

Manifest version 2 of chrome extensions will no longer support use of eval or new Function on regular extension pages. My chrome extension uses a UI Framework (Kendo UI) on the options page that makes use of these mechanisms and therefore I'm looking for a solution.

According to this session from IO 2012 the idea is to put the corresponding page into a sandbox and load it into the extension via an iframe.

Here is a simplified example what I'm trying to do: https://gist.github.com/3058943

manifest.json:

{
 "name": "Sandbox test",
 "manifest_version": 2,
 "options_page": "main.html",
 "sandbox": {
    "pages": [ "index.html" ]
  }
}

main.html:

<html>
  <head></head>
  <body>
    <iframe id="iframe" src="index.html" ></iframe>
  </body>
</html>

index.html:

<html>
  <head></head>
  <body>
    <h1>Inside the sandbox</h1>
  </body>
</html>

When I load the options page in this example, I'm getting the error message:

Denying load of chrome-extension://fahdnpkbgfjkocogbjlljfbhnljcehoh/index.html. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by web pages.

I don't think that each sandboxed page is also supposed to be a web_accessible_resources. But even when I try to define the sandboxed pages also as web_accessible_resources in the manifest file, then the sandboxed page gets loaded but use of new Function inside the iframe is still blocked.

Upvotes: 3

Views: 3733

Answers (1)

toberndo
toberndo

Reputation: 51

The above described error message occurs on Chrome 20.0.1132.47.

I tested with the dev channel version 21.0.1180.15 and here the sandboxed iframe loads without problems.

Upvotes: 1

Related Questions