A Chrome extension to find and fix common form problems.
When released, this extension will be available from the Chrome Web Store.
For the moment, you have the option to either
- Download the latest extension, or
- To build from source
The latest version of the extension can be downloaded with the following URL: https://github.com/GoogleChromeLabs/form-troubleshooter/releases/latest/download/form-troubleshooter-extension.zip
Note that you can download specific versions using by visiting the
releases page on GitHub and downloading the
form-troubleshooter-extension.zip
file.
Once you have downloaded the zip file, extract in your preferred location.
Note that you will need to have Node.js 12 or later to build the extension.
- Download the code or clone the
repo:
git clone [email protected]:GoogleChromeLabs/form-troubleshooter.git
- Install dependencies:
npm install
- Build the extension:
npm run build
-
Enable Developer mode
-
Click the Load unpacked button and select the extension's folder:
- If you downloaded
form-troubleshooter-extension.zip
, the extension's folder will be the location of the extracted folder. - If you built the extension from source, the extension's folder will be the
build/
folder of the repository.
- If you downloaded
-
You can pin the extension so its icon is always visible: from the Chrome Extensions menu, select Form Troubleshooter
Visit a page you want to check, then click the extension icon. The extension retrieves and audits form elements and attributes every time the icon is clicked.
The extension popup has three sections:
- Recommendations
- Common mistakes
- Form details
Save as HTML saves the report as a local HTML file.
You can try out the extension on the test page form-problems.glitch.me.
To develop and test the extension locally, first follow the steps to build from source.
Run the local web server with Hot Module Reloading (HMR):
npm run dev
Open http://localhost:8080/.
Note that developing in this mode requires you to bring your own form data. This can be achieved by referencing one of
the existing data files in the test-data
folder using the data
query string parameter:
- http://localhost:8080/?data=/test-data/form-problems.json
- http://localhost:8080/?data=/test-data/score.json
- http://localhost:8080/?data=/test-data/shadow-dom.json
Or by loading a saved form file from the more menu in the top right of the popup.
# one off test run
npm run test
# continuously watch for changes
npm run test:watch
Before contributing any code, make sure that code has been linted.
npm run lint
# reformat files automatically
npm run pretty
- The extension is designed to be used as a tool, not to confirm whether code is 'right' or 'wrong'. Form usage is often complex (especially for high-traffic sites) so it's difficult to provide form code validation that is appropriate across a variety of sites.
- Some errors found by the extension may represent known problems, or be triggered by 'incorrect' code that is justified for reasons outside the scope of the extension. In particular, many high-traffic sites use form code in a variety of ways to function at scale and integrate with legacy and third-party systems. The same code may not be appropriate for smaller-scale sites.
However, please provide feedback or file a bug for audit results that appear to be incorrect.
The extension checks the current page for form and form field elements each time it's opened.
- The extension icon is clicked to open popup.html.
- popup.js sends a message to content-script.js that the popup
has opened (
popup opened
). - content-script.js traverses the DOM including the shadow DOM and
iframe
s. - content-script.js stores a DOM representation using
chrome.storage
which will be used by content-script.js. - content-script.js sends a message via background.js that the DOM has been inspected
(
dom inspected
). - content-script.js stores form data using
chrome.storage
. - content-script.js sends a message that element data has been stored
(
stored element data
). - On receiving the message, popup.js gets the data from chrome.storage.
- popup.js runs the audits defined in audits.js, to check the form elements and attributes in the page.
- popup.js displays an overview of form and form field data in popup.html.
- popup.js displays results of the audits in popup.html.
Feedback and audit suggestions welcome!
- Link to and/or highlight problematic elements.
- Link to items in the regular DOM.
- Link to items in shadow DOM.
- Link to items in iframes.
- Move code for displaying audit results out of audits.js.
- Move constants to external file.
- Check for forms (or other elements) that don't have a closing tag.
- Check for invalid
type
attribute values, for example<input type="check">
. - Suggest alternatives to invalid attribute names, e.g. for
autcomplete
.
This is not a Google product.