Copy on Select 2

Tests

Overview and Test Preparation

Process the following tests on Firefox Nightly (during add-on development only), on the minimum supported Firefox, on Debian stable's Firefox, and on an up-to-date ungoogled chromium flatpak. Unless otherwise stated, install the XPI or CRX package with C-o and remove it again when done testing.

The last note above is rather crucial: If you have previously forgotten to do so and notice the presence of some old version of this add-on when you start one of the test browsers below, better remove that version and restart the browser before installing the new version. Otherwise you may end up chasing all sorts of funny phantom symptoms.

Monitor Clipboard vs. Primary Selection

Execute the following command in a terminal to monitor and compare clipboard and primary selection on Wayland or X11:

watch -t -n1 -x bash -c \
      'c=$( wl-paste ) p=$( wl-paste --primary )
       printf "c:%3d %-74.74s\n" "${#c}" "${c@Q}"
       printf "p:%3d %-74.74s\n" "${#p}" "${p@Q}"
       test "$c" = "$p" && echo PASS || echo FAIL'
watch -t -n1 -x bash -c \
      'c=$( xclip -o -se c ) p=$( xclip -o -se p )
       printf "c:%3d %-74.74s\n" "${#c}" "${c@Q}"
       printf "p:%3d %-74.74s\n" "${#p}" "${p@Q}"
       test "$c" = "$p" && echo PASS || echo FAIL'

Prepare a Local Test File and HTTP Server

It is hard to otherwise find HTTP(non-S) servers and at some time (?) copying from HTTP-served pages has behaved differently than from HTTPS-served pages.

cp ~/work/copy-on-select-2/content/simple.html /tmp/simple.html
while :; do
  { echo $'HTTP/1.1 200 OK\r\n\r\n'; cat /tmp/simple.html; } |
  nc -l 8080
done

Basic Functionality

Reset all options before performing the following tests.

After the first test pass, switch on the use of the native copy command; then perform a second pass on below tests.

Regular Text (PASS)

When shall we three meet again
In thunder, lightning, or in rain?

Disabled Text Area Text (FAIL)

Iframe Text (PASS)

(The iframe tests result in a FAIL on Firefox 115. And I am not going to document that otherwise or even work around it!)

Cross-Site Iframe Text (PASS)

Mixed Open Shadow DOM Text (BREAK)

When shall we three meet again
In thunder, , or in rain?

Mixed Closed Shadow DOM Text (BREAK)

When shall we three meet again
In thunder, , or in rain?

Rich Text (PASS)

When shall we three meet again
In thunder, lightning, or in rain?

Rich Text Paste (with Native Copy Only)

Copy-on-select the rich text from the previous test; paste it into the following content-editable text box and ensure that the markup is preserved.

Non-Text (FAIL/PASS)

Select the following image. Without native copy that should clear the primary selection, but not the clipboard. With native copy it should clear both.

Read-Only Text Area Text (PASS)

Read-Only Text Box Text (PASS)

ARIA Read-Only Text Box Text (PASS)

Simulate an input field that has been made read-only programatically, like GitHub has it.

ARIA Read-Only Text Area Text (PASS)

Tests Requiring Separate Pages

Tests Requiring External Pages

Input Fields

Reset all options before performing the following tests; then process below tests repeatedly as follows:

  1. Process the tests with options reset to default and ensure that the tests FAIL. Even in the content-editable input fields. (GitHub issue 12, GitHub issue 16)
  2. Select Alt as input inversion modifier; process the tests without pressing the Alt key and ensure that the tests FAIL.
  3. Process the tests while pressing the Alt key and ensure that the tests PASS.
  4. Reset all options again; switch on the input field option; process the tests and ensure that the tests PASS. (GitHub issue 6)
  5. Select Alt as input inversion modifier; process the tests without pressing the Alt key and ensure that the tests PASS.
  6. Process the tests while pressing the Alt key and ensure that the tests FAIL.

Text Box Text (FAIL/PASS)

Text Area Text (FAIL/PASS)

Content-Editable Input Field (FAIL/PASS)

Content-editable input field that inherits its editable property from a surrounding element.

When shall we three meet again
In thunder, lightning, or in rain?

Mixed Content-Editable Input Field (FAIL/PASS)

Partially content-editable input field, where the middle two lines are not content-editable. Ensure to include text from the first and last line in the selection.

When shall we three meet again
In thunder, lightning, or in rain?
When the hurlyburly's done,

When the battle's lost and won.

Option Page

Save and Reset

Error Handling

Dependency Handling

Dark Theme

Extended Functionality

Non-Main Button Clicks (PASS)

Main Button Clicks into Existing Selection (PASS)

Triple-Click Whitespace Trimming (FF only, FAIL)

When shall we three meet again
In thunder, lightning, or in rain?

Multi-Range Selection Separation (FF only, FAIL)

When shall we three meet again

In thunder,lightning,or in rain?

Control-Clicks with Existing Selection (FF only, PASS)

Ensure that the multi-range selection separator is on default %0a; select word "hurlyburly" with a double-click; copy some different text from a non-browser source; control-click outside of the existing selection and ensure that this copies the word "hurlyburly" to the clipboard again, but without any leading or trailing newline.

Content Pages

Dark Theme on Onboarding Page

Dark Theme on Index Page

Random Test Notes

Setting up Firefox Installations and Profiles for Testing this Add-On

Define FF major version, tarball location, and installation type (one of tmp or collateral for a temporary or permanent installation, respectively):

version=...
tarball=...
type=...

Create a FF installation:

cd ~/work/copy-on-select-2/$type
rm -rf firefox
tar xf $tarball
chmod -R u+w firefox-$version
rm -rf firefox-$version
mv firefox firefox-$version

# for immutable FFs only
mkdir firefox-$version/distribution
cat << 'EOF' > firefox-$version/distribution/policies.json
{
  "policies": {
    "DisableAppUpdate": true
  }
}
EOF

# for very immutable FFs only
chmod -R a-w firefox-$version

Create a sane test profile. This still lets come through the "Choose What I Share" prompt, but pretty much nothing else.

cd ~/work/copy-on-select-2/$type
rm -rf tprof-$version
mkdir tprof-$version
cat << 'EOF' > tprof-$version/prefs.js
// do not remove this line
user_pref("app.shield.optoutstudies.enabled", false);
user_pref("browser.aboutwelcome.enabled", false);
user_pref("browser.discovery.enabled", false);
user_pref("browser.newtabpage.enabled", false);
user_pref("browser.open.lastDir", "~/work/copy-on-select-2/dist");
user_pref("browser.shell.checkDefaultBrowser", false);
user_pref("browser.startup.couldRestoreSession.count", 2);
user_pref("browser.startup.homepage", "about:blank");
user_pref("browser.tabs.warnOnClose", false);
user_pref("browser.toolbars.bookmarks.visibility", "never");
user_pref("browser.translations.automaticallyPopup", false);
user_pref("browser.warnOnQuit", false);
user_pref("browser.warnOnQuitShortcut", false);
user_pref("datareporting.healthreport.uploadEnabled", false);
user_pref("devtools.chrome.enabled", true);
user_pref("devtools.debugger.remote-enabled", true);
user_pref("layout.css.devPixelsPerPx", "1.25");
user_pref("toolkit.telemetry.reportingpolicy.firstRun", false);
user_pref("xpinstall.signatures.required", false);
EOF

To start a temporarily installed FF as set up above execute:

( cd ~/work/copy-on-select-2 &&
  ./tmp/firefox-$version/firefox -profile tmp/tprof-$version ) &