We have some tests already, merged in https://github.com/web-platform-tests/wpt/pull/40330
To run them, you can run (from a source dir) e.g.:
./mach wpt html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-source-media-env-change.html
and the same by substituting the path to the other tests (you can also specify multiple paths iirc).
It should run the browser, and run some stuff, and then say something like:
0:25.62 TEST_START: /html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-source-media-env-change.html
0:26.35 TEST_END: Test FAIL. Subtests passed 1/1. Unexpected 1
at which point the test is passing, but we expected it to fail. To remove this expectation (so that it's expected to pass), you can remove e.g. this file:
same goes for the other test in the WPT PR of course. If you upload a patch containing all this, I can push it to our CI so that all tests are going to run, and we'll see if we need to modify more things.
The test themselves are at https://searchfox.org/mozilla-central/source/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-source-media-env-change.html in our source dir. If you need to modify them, or test more things, you can simply modify this file and the modifications will be auto-synchronized to the upstream copy.