chromium-notes

Testing

Google Tests (General)

Example: the blink_platform_unittests & blink_unittests (previously webkit_unit_tests) targets:

./out/Debug/blink_unittests --gtest_filter="HTMLPreloadScannerDocumentTest.XHRResponseDocument"
./out/Debug/blink_platform_unittests --gtest_filter="ResourceFetcherTest.UseExistingResource"
./out/Debug/blink_platform_unittests --gtest_filter="ResourceFetcherTest.*"

Useful gtest flags:

Browser tests

SSH & Display

Running a non-unit-test from a remote device over SSH will likely result in the test failing due to display issues. This requires running export DISPLAY=:20 to fix.

Misc tips

Browser test tips: https://chromium.googlesource.com/chromium/src/+/master/content/public/test/README.md.

Unit tests

Integrating RuntimeEnabledFeatures

Runtime enable features have automatically-generated Scope* classes to help enable features for unit tests. See https://source.chromium.org/search?q=Scoped.*ForTest%20file:test.cc%20file:blink&sq= for example.

WPTs & Layout Tests

Misc useful links:

Running layout tests:

third_party/blink/tools/run_web_tests.py -t Debug http/tests/security/referrer-policy-conflicting-policies.html external/wpt/workers

Useful flags:

WPT results

The last set of test results are always available at:

./out/Debug/layout-test-results/results.html

Server output

Python server output can be found at:

./out/<Dir>/layout-test-results/wptserve_stdout.txt
./out/<Dir>/layout-test-results/wptserve_stderr.txt

Useful run_web_tests.py flags

Cross-origin tests

If you want to use a cross-origin in a test, you have two options:

  1. Substitution tests
    • Make the test name of the format test-name.sub.html or test-name.sub.https.html
    • This makes the test run through the server-side substitutor(?) before it is served
    • Therefore you can use things like the following to create origins:
      • http://:/html/
      • http://:/html/
  2. Import the get-host-info helper
    • <script src="/common/get-host-info.sub.js"></script>
    • URL(get_host_info().HTTPS_REMOTE_ORIGIN + '/worklets/resources/referrer-checker.py');

Public and private networks

Sometimes you have to test Chrome’s behavior on public and private networks. See the following resources for doing so:

Here’s an example:

./out/Debug/chrome --no-sandbox --enable-experimental-web-platform-features --enable-features=FencedFrames,SharedStorageAPI --ip-address-space-overrides=127.0.0.1:8445=private,127.0.0.1:8446=public https://fenced-frames.glitch.me/

Misc WPT/testharness things