Skip to content

chrome带有whitelist的API browser_tests测试

Haojian Wu edited this page Jul 13, 2013 · 2 revisions

启动白名单的web app

命令行参数:chrome.exe --whitelisted-extension-id=XXX。 extension_id查看方法,load进chromium后在extension页面查看

manifestion.json文件key域,官方文档解释:

"key" : public key. This value can be used to control the unique ID of an extension, app, or theme when it is loaded during development.

To get a suitable key value, first install your extension from a .crx file (you may need to upload your extension or package it manually). Then, in your user data directory, look in the file Default/Extensions///manifest.json. You will see the key value filled in there.

key域一般不需要用到,用途是保证安装在chrome上时,ID是唯一的并且不变,不管load多少次。一般用在chromium的browser_tests测试中。 获得“public key”方法:使用chromium的package功能把extension源码打包成crx安装文件,然后安装。生成Default/Extensions/<extensionId>/<versionString>/manifest.json文件,文件中就有key的值,记录下来复制到源码的manifestion文件中即可。

Chromium限制性API的browser_test测试

  • 测试的extension代码需要使用whitelist启动,启动参数需要指定extension id到whitelist中。
  • manifest中key域,保证每次加载进来的extension的id保持不变,与1对应。
  • manifest中要有相关的permission域, 如permission: ["systemInfo.storage"]

chrome extension api权限控制相关C++代码

  • chrome/common/extensions/permissions/api_permission.h
  • chrome/common/extensions/permissions/chrome_api_permissions.cc
  • chrome/common/extensions/api/_permission_features.json // 控制API能够被哪种类型web app使用(extension, packaged_app, hosted_app, platform_app)
  • chrome/common/extensions/api/_api_features.json // API feature, 匹配manifest文件的permission field

Tech-Notes

LLVM/Clang

C/C++

Linux

Vim

Tools

Others

Chromium-Dev tips

Clone this wiki locally