Closed Bug 1961064 Opened 9 months ago Closed 8 months ago

Intermittent toolkit/components/extensions/test/xpcshell/test_ext_contentscript_order.js | single tracking bug

Categories

(WebExtensions :: General, defect, P5)

defect

Tracking

(firefox140 fixed)

RESOLVED FIXED
140 Branch
Tracking Status
firefox140 --- fixed

People

(Reporter: intermittent-bug-filer, Assigned: robwu)

References

Details

(Keywords: intermittent-failure, intermittent-testcase, Whiteboard: [addons-jira])

Attachments

(1 file)

Filed by: chorotan [at] mozilla.com
Parsed log: https://treeherder.mozilla.org/logviewer?job_id=504353767&repo=mozilla-central
Full log: https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/O5kaTSsHRAOS0eFasDNWXA/runs/0/artifacts/public/logs/live_backing.log


task 2025-04-17T01:11:09.597Z] 01:11:09     INFO -  TEST-PASS | uriloader/exthandler/tests/unit/test_punycodeURIs.js | took 1173ms
[task 2025-04-17T01:11:09.606Z] 01:11:09     INFO -  Retrying tests that failed when run in parallel.
[task 2025-04-17T01:11:09.612Z] 01:11:09     INFO -  TEST-START | xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_contentscript_order.js
[task 2025-04-17T01:11:10.621Z] 01:11:10  WARNING -  TEST-UNEXPECTED-FAIL | xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_contentscript_order.js | xpcshell return code: 0
[task 2025-04-17T01:11:10.633Z] 01:11:10     INFO -  TEST-INFO took 1010ms
[task 2025-04-17T01:11:10.633Z] 01:11:10     INFO -  >>>>>>>
[task 2025-04-17T01:11:10.634Z] 01:11:10     INFO -  (xpcshell/head.js) | test MAIN run_test pending (1)
[task 2025-04-17T01:11:10.634Z] 01:11:10     INFO -  (xpcshell/head.js) | test run_next_test 0 pending (2)
[task 2025-04-17T01:11:10.634Z] 01:11:10     INFO -  (xpcshell/head.js) | test MAIN run_test finished (2)
[task 2025-04-17T01:11:10.634Z] 01:11:10     INFO -  running event loop
[task 2025-04-17T01:11:10.634Z] 01:11:10     INFO -  xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_contentscript_order.js | Starting setup check_remote
[task 2025-04-17T01:11:10.635Z] 01:11:10     INFO -  (xpcshell/head.js) | test check_remote pending (2)

These failures started immediately after the test landed in bug 1792685.
I looked at recent failures, and the assertion failures (relevant parts pasted below) show that the style sheets are applied in an unexpected order:

From https://searchfox.org/mozilla-central/rev/4bd620c218a01568d541453ce3b215ebf55bca63/toolkit/components/extensions/test/xpcshell/test_ext_contentscript_order.js#374-383 :

TEST-UNEXPECTED-FAIL | xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_contentscript_order.js | test_css_order - [test_css_order : undefined] start_2.css (not cached) applies before frame.onload - "1" == "2"
TEST-UNEXPECTED-FAIL | xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_contentscript_order.js | test_css_order - [test_css_order : undefined] start_3.css (cached, blocked on start_2.css) applies before frame.onload - "2" == "3"

This shows something interesting:

  • The first assertion failure implies that the --css-start-12 variable from start_1.css was applied (value "1") instead of value "2" expected from start_2.css.
  • The second assertion failure implies that the --css-start-23 variable from start_2.css was applied (value "2") instead of value "3" expected from start_3.css.
  • We expect the styles to apply in the order of start_1.css, start_2.css, start_3.css. With just the first assertion error, one may think that start_2.css did not apply, but the second assertion shows that it did. Therefore the conclusion is that the styles from start_1.css unexpectedly applied after start_2.css (instead of before).
    • The logs also suggest that start_3.css did either not apply, or applied before start_2.css (instead of after). There is not enough information to tell which of the two is the case.
  • I reproduced the issue locally, and with additional logging I can confirm that the scripts and styles are scheduled as expected. The issue is likely somewhere between AddSheet and/or getComputedStyle(...).getPropertyValue(...).

There are additional test failures (later) after the initial one, which show the same (incorrect) values.

From https://searchfox.org/mozilla-central/rev/4bd620c218a01568d541453ce3b215ebf55bca63/toolkit/components/extensions/test/xpcshell/test_ext_contentscript_order.js#307 :

TEST-UNEXPECTED-FAIL | xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_contentscript_order.js | test_css_order - [test_css_order : 145] Got expected css order: --css-start-12 should be 2 - Expected: 2, Actual: 1 - false == true

From https://searchfox.org/mozilla-central/rev/4bd620c218a01568d541453ce3b215ebf55bca63/toolkit/components/extensions/test/xpcshell/test_ext_contentscript_order.js#308 :

TEST-UNEXPECTED-FAIL | xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_contentscript_order.js | test_css_order - [test_css_order : 145] Got expected css order: --css-start-23 should be 3 - Expected: 3, Actual: 2 - false == true

See Also: → 1792685

I can reproduce the issue locally, but only on a release build, not on a debug build.

When addSheet is used and mStyleSetFilled is true in Document::AddAdditionalStyleSheet, then the stylesheets are appended in the expected order.

When mStyleSetFilled is false, it is populated later via Document::FillStyleSet, in Document::FillStyleSetDocumentSheets. The AppendSheetsToStyleSet method appends the stylesheet in the reverse order. Consequently, the order of stylesheets is start_3.css, start_2.css, start_1.css instead of the expected start_1.css, start_2.css, start_3.css.

When I fix the order to be non-reversed, the failure goes away. I'll attach a patch.

Assignee: nobody → rob
Whiteboard: [addons-jira]
Pushed by rob@robwu.nl: https://hg.mozilla.org/integration/autoland/rev/730be97ab77d Fix order of windowUtils.addSheet r=emilio
Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 140 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: