Closed Bug 1856464 Opened 2 years ago Closed 2 years ago

Assert.rejects in ContentTask.spawn: TypeError: can't access property "filename", stack is null

Categories

(Testing :: Mochitest, defect, P2)

defect

Tracking

(firefox-esr115 wontfix, firefox118 wontfix, firefox119 wontfix, firefox120 wontfix, firefox121 fixed)

RESOLVED FIXED
121 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox118 --- wontfix
firefox119 --- wontfix
firefox120 --- wontfix
firefox121 --- fixed

People

(Reporter: robwu, Assigned: robwu)

References

(Regression)

Details

(Keywords: regression, Whiteboard: [addons-jira])

Attachments

(2 files)

The original contentPage.spawn (now contentPage.spawnLegacy) method used to successfully log a message when Assert.rejects is used. But the new contentPage.spawn method prints an error instead. E.g. as seen in https://phabricator.services.mozilla.com/D174513?id=700812#inline-1051275 :

 0:06.76 INFO "Register service worker from a content webpage (disallowed redirects)"
 0:06.77 pid:1405152 JavaScript error: /home/rpl/my/mozlab/mc-trypush/testing/xpcshell/head.js, line 929: TypeError: can't access property "filename", stack is null
 0:06.77 INFO "Register service worker from a content webpage (with import redirect)"
 0:06.77 INFO "CONSOLE_MESSAGE: (error) [JavaScript Error: "TypeError: can't access property "filename", stack is null" {file: "/home/rpl/my/mozlab/mc-trypush/testing/xpcshell/head.js" line: 929}]
do_report_result@/home/rpl/my/mozlab/mc-trypush/testing/xpcshell/head.js:929:42
receiveMessage@resource://testing-common/SpecialPowersChild.sys.mjs:320:32
_do_main@/home/rpl/my/mozlab/mc-trypush/testing/xpcshell/head.js:245:6
_execute_test@/home/rpl/my/mozlab/mc-trypush/testing/xpcshell/head.js:592:5
@-e:1:1
"

Set release status flags based on info from the regressing bug 1648545

... and make sure that Assert.rejects(Promise.resolve()) resolves even
if the _reporter override does not throw. This is needed for the test
to run to completion; otherwise the new Harness_sanity tests get stuck.

An extra test has been added to test_assert.js to verify that under
normal circumstances, Assert.rejects(Promise.resolve()) rejects.

Assert.rejects uses callbacks in a way that the stack no longer includes
the original caller in the stack when the stack is generated.
Consequently, when AssertionError tries to identify the caller, it is
unable to do so, resulting in a null stack.

This null stack is passed by the SpecialPowers glue to
do_report_result in xpcshell/head.js, which doesn't expect a null
stack, and consequently the following error is reported:
"TypeError: can't access property "filename", stack is null"

To fix this issue, we save the stack (including the caller) upon
entering Assert.rejects, and forward that to AssertionError.

I have added some necessary test coverage. While doing so I noticed that there are more issues beyond the initial report.

In the test coverage, I intentionally added cases for rejection vs non-rejection, but not for rejection with incorrect error. Some work on that had started before in bug 1480075 and can be covered there.

See Also: → 1480075

The severity field is not set for this bug.
:jmaher, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(jmaher)
Severity: -- → S4
Flags: needinfo?(jmaher)
Priority: -- → P2
Pushed by rob@robwu.nl: https://hg.mozilla.org/integration/autoland/rev/076438699342 Add test coverage for Assert.rejects itself r=jmaher https://hg.mozilla.org/integration/autoland/rev/16e6c8b1d450 Include stack in Assert.rejects r=jmaher
Flags: needinfo?(rob)
Pushed by rob@robwu.nl: https://hg.mozilla.org/integration/autoland/rev/d91e54437030 Add test coverage for Assert.rejects itself r=jmaher https://hg.mozilla.org/integration/autoland/rev/4a8a737bf972 Include stack in Assert.rejects r=jmaher

Backed out for causing failures on test_SpecialPowersSandbox.html

[task 2023-10-25T22:09:11.797Z] 22:09:11     INFO - TEST-PASS | testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html | Got stack for: Thing - 1 == 2 
[task 2023-10-25T22:09:11.797Z] 22:09:11     INFO - Buffered messages finished
[task 2023-10-25T22:09:11.800Z] 22:09:11     INFO - TEST-UNEXPECTED-FAIL | testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html | Stack does not contain /test_SpecialPowersSandbox.html:: @http://mochi.test:8888/tests/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html?currentTestURL=testing%2Fmochitest%2Ftests%2FHarness_sanity%2Ftest_SpecialPowersSandbox.html&closeWhenDone=1&showTestReport=false&expected=pass:68:16
[task 2023-10-25T22:09:11.800Z] 22:09:11     INFO - execute@resource://testing-common/SpecialPowersSandbox.sys.mjs:139:12
[task 2023-10-25T22:09:11.801Z] 22:09:11     INFO - _spawnTask@resource://testing-common/SpecialPowersChild.sys.mjs:1654:15
[task 2023-10-25T22:09:11.802Z] 22:09:11     INFO - receiveMessage@resource://testing-common/SpecialPowersChild.sys.mjs:257:21
[task 2023-10-25T22:09:11.802Z] 22:09:11     INFO - JSActor query*receiveMessage@resource://testing-common/SpecialPowersParent.sys.mjs:1385:14
[task 2023-10-25T22:09:11.802Z] 22:09:11     INFO - JSActor query*spawn@resource://testing-common/SpecialPowersChild.sys.mjs:1583:17
[task 2023-10-25T22:09:11.802Z] 22:09:11     INFO - doApply@resource://testing-common/WrapPrivileged.sys.mjs:117:18
[task 2023-10-25T22:09:11.803Z] 22:09:11     INFO - apply/<@resource://testing-common/WrapPrivileged.sys.mjs:252:30
[task 2023-10-25T22:09:11.804Z] 22:09:11     INFO - wrapExceptions@resource://testing-common/WrapPrivileged.sys.mjs:205:12
[task 2023-10-25T22:09:11.804Z] 22:09:11     INFO - apply@resource://testing-common/WrapPrivileged.sys.mjs:236:12
[task 2023-10-25T22:09:11.805Z] 22:09:11     INFO - SpecialPowers.spawn@http://mochi.test:8888/tests/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html?currentTestURL=testing%2Fmochitest%2Ftests%2FHarness_sanity%2Ftest_SpecialPowersSandbox.html&closeWhenDone=1&showTestReport=false&expected=pass:66:28
[task 2023-10-25T22:09:11.805Z] 22:09:11     INFO - interceptDiagnostics@http://mochi.test:8888/tests/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html?currentTestURL=testing%2Fmochitest%2Ftests%2FHarness_sanity%2Ftest_SpecialPowersSandbox.html&closeWhenDone=1&showTestReport=false&expected=pass:30:11
[task 2023-10-25T22:09:11.806Z] 22:09:11     INFO - @http://mochi.test:8888/tests/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html?currentTestURL=testing%2Fmochitest%2Ftests%2FHarness_sanity%2Ftest_SpecialPowersSandbox.html&closeWhenDone=1&showTestReport=false&expected=pass:127:23
[task 2023-10-25T22:09:11.806Z] 22:09:11     INFO - async*add_task/nextTick/<@http://mochi.test:8888/tests/SimpleTest/SimpleTest.js:2189:34
[task 2023-10-25T22:09:11.807Z] 22:09:11     INFO - nextTick@http://mochi.test:8888/tests/SimpleTest/SimpleTest.js:2233:11
[task 2023-10-25T22:09:11.807Z] 22:09:11     INFO - setTimeout handler*SimpleTest_setTimeoutShim@http://mochi.test:8888/tests/SimpleTest/SimpleTest.js:922:41
[task 2023-10-25T22:09:11.807Z] 22:09:11     INFO - add_task@http://mochi.test:8888/tests/SimpleTest/SimpleTest.js:2137:17
[task 2023-10-25T22:09:11.808Z] 22:09:11     INFO - @http://mochi.test:8888/tests/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html?currentTestURL=testing%2Fmochitest%2Ftests%2FHarness_sanity%2Ftest_SpecialPowersSandbox.html&closeWhenDone=1&showTestReport=false&expected=pass:38:9
[task 2023-10-25T22:09:11.809Z] 22:09:11     INFO -  
[task 2023-10-25T22:09:11.809Z] 22:09:11     INFO -     SimpleTest.ok@SimpleTest/SimpleTest.js:426:16
[task 2023-10-25T22:09:11.811Z] 22:09:11     INFO -     @testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html?currentTestURL=testing%2Fmochitest%2Ftests%2FHarness_sanity%2Ftest_SpecialPowersSandbox.html&closeWhenDone=1&showTestReport=false&expected=pass:141:11
[task 2023-10-25T22:09:11.811Z] 22:09:11     INFO -     async*add_task/nextTick/<@SimpleTest/SimpleTest.js:2189:34
[task 2023-10-25T22:09:11.812Z] 22:09:11     INFO -     nextTick@SimpleTest/SimpleTest.js:2233:11
[task 2023-10-25T22:09:11.812Z] 22:09:11     INFO -     setTimeout handler*SimpleTest_setTimeoutShim@SimpleTest/SimpleTest.js:922:41
[task 2023-10-25T22:09:11.812Z] 22:09:11     INFO -     add_task@SimpleTest/SimpleTest.js:2137:17
[task 2023-10-25T22:09:11.813Z] 22:09:11     INFO -     @testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html?currentTestURL=testing%2Fmochitest%2Ftests%2FHarness_sanity%2Ftest_SpecialPowersSandbox.html&closeWhenDone=1&showTestReport=false&expected=pass:38:9
[task 2023-10-25T22:09:11.813Z] 22:09:11     INFO - TEST-PASS | testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html | Got stack for: Hmm - 1 == 1 
Flags: needinfo?(rob)
Flags: needinfo?(rob)
Pushed by rob@robwu.nl: https://hg.mozilla.org/integration/autoland/rev/99c934546f5a Add test coverage for Assert.rejects itself r=jmaher https://hg.mozilla.org/integration/autoland/rev/99f5a11e1027 Include stack in Assert.rejects r=jmaher
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 121 Branch

The patch landed in nightly and beta is affected.
:robwu, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox120 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(rob)
Flags: needinfo?(rob)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: