dimanche 22 mai 2016

How do I test a context menu entry in a Chrome Extension?

I have a Chrome extension that adds an entry to the browser's context menu, that allows a user to copy the top-level heading of a page to the clipboard.

Example:

Given the following HTML:

<h1>My Page</h1>

Right clicking on the page, selecting Plugin Name > Copy Title, will copy the string "My Page" to the clipboard. This should only work on a specified domain.

I'd like to write tests to ascertain that:

  • The context menu entry only appears on the specified domain
  • When on the specified domain, if I right click the page and select "Copy Title" that the correct string (i.e. the page's title) is copied to the clipboard.

How do I do that?

I'm not asking for the code, just for which tools are best suited to this job and a vague idea of the best order to do things.

Aucun commentaire:

Enregistrer un commentaire