commit | 5fd5177cae3c19b9f97369fdb984cea89621cfaa | [log] [tgz] |
---|---|---|
author | Ben Rohlfs <brohlfs@google.com> | Fri Dec 22 17:40:18 2023 +0100 |
committer | Ben Rohlfs <brohlfs@google.com> | Fri Dec 22 17:40:18 2023 +0100 |
tree | 4c0a65e06d0e53c57df0e74279ca812a21f3a6c6 | |
parent | ba97b456d4db19ec43a1e32ca31cd123dfc16f99 [diff] |
Remove support for INJECT_JS_PLUGIN and INJECT_JS_MODULE_PLUGIN Content Security Policy for extensions does not allow injecting arbitrary JS. We have considered passing a list of URLs from the extension to the web app instead, but that is non-trivial to do, because they also cannot access the `window` object of each other. The extension could add an element to the DOM and set an attribute on that. The web app would then read the attribute and load those plugins instead of the ones listed in the server config. Apart from adding complexity the disadvantage is that the web app would have to be changed, and thus you could not use the concept for existing open source servers. There is a trivial workaround though: You can just redirect an exsiting plugin to your new plugin. Every Gerrit server typically has a plugin that can be replaced during development, so this is not much of a limitation. Google-Bug-Id: b/317481553 Release-Notes: Remove INJECT_JS_PLUGIN and INJECT_JS_MODULE_PLUGIN Change-Id: If954960ad56aba5595c6ec029ce8211fcb6ec5b0
Gerrit FE Dev helper is a Chrome extension that will focus on helping frontend developers on Gerrit development.
As mentioned in readme from polygerrit-ui, we already support to start your local host for developing / debugging / testing, but it has quite a few restrictions:
To solve these pain points, Tao Zhou created this Chrome extension. It proxies all assets requests or any requests to a local HTTP server, and has the ability to inject any plugins exposed by the local HTTP server.
See in release notes and Features below.
The easiest is to install from the Chrome web store here: https://chrome.google.com/webstore/detail/gerrit-fe-dev-helper/jimgomcnodkialnpmienbomamgomglkd.
After you have installed and enabled the extension, you should see something similar to demo.png.
To build from source:
npm install npm run build
Then you should have gerrit_fe_dev_helper.zip
that you can test with.
yarn start
Or if you are developing a plugin, serve your plugin via a local HTTP server via any means.
Example:
npx http-server -c-1 --cors
Gerrit dev helper is enabled
, and now your Gerrit assets should be loaded from your local HTTP serverThe extension comes with a set of default rules, but you can change the rules by clicking the extension icon again.
The extension supports different type of rules:
For existing plugins just redirect
from the where the plugin is normally loaded from to http://localhost:8081/plugins/my-plugin.js
and put your local plugin file into the polygerrit-ui/app/plugins
folder.
For new plugins you also have to use a redirect
rule, because the Chrome extension is not allowed to inject JavaScript from arbitrary source by Content Security Policy. The easiest option is to pick the most simple or irrelevant plugin that your Gerrit server has, and redirect from that.
npm run build
.Developer Mode
.Load Unpacked
.dist
directory.As a Google developer you will have to add a key
to the manifest.json
in the dist/
directory as documented here: http://go/extension-identification#i%E2%80%99m-developing-a-chrome-extension-on-my-computer
This section is for members of Google's developer team only.
manifest.json
and package.json
.npm run build
.Upload dogfood version
button.Upload new package
button.Please don't hesitate to contact dhruvsri@google.com for support on this extension.