Bug: C-C TB mochitest: TypeError: can't access property "URI", tab.folder is undefined
Status: RESOLVED
Priority: --
Resolution: FIXED
Created: 2023-01-25 06:36:36+00:00
Resolved: 2023-02-07 06:42:21+00:00

I noticed the following errors in my local mochitest of DEBUG version
of C-C TB.
```
 GECKO(390025)	 Message: TypeError: can't access property "URI", tab.folder is undefined
```
This was not noticed in 10 days ago. So, it is a relatively new error.

I see 36 of them. (I probably should file bugzilla entries for the other top three errors.)
An excerpt from the summary of my local log:
```
JavaScript errors Without Console prefix
     56 JavaScript error: resource:///modules/DevToolsStartup.sys.mjs, line 696: TypeError: can't access property "parentNode", mainKeyset is null
---> 36	  Message: TypeError: can't access property "URI", tab.folder is undefined
     17 JavaScript error: chrome://global/content/elements/browser-custom-element.js, line 856: TypeError: this.ownerGlobal.gBrowser.getTabForBrowser is not a function
      5	  [calICSCalendar] Backup failed, no copy: TypeError: can't access property "copyTo", oldFile is undefined
      1 JavaScript error: resource:///modules/ExtensionsUI.jsm, line 358: TypeError: lazy.addonsBundle.getFormattedString is not a function
      1 JavaScript error: chrome://messenger/content/messengercompose/MsgComposeCommands.js, line 7283: TypeError: can't access property "incomingServer", account is null
      1 JavaScript error: chrome://messenger/content/mailWidgets.js, line 888: TypeError: can't access property "loaded", item is null
      1	  Message: TypeError: URL constructor: https:// is not a valid URL.
```

When I look at someone's debug job on treeherder, I also see it.
So it is for real. Nothing to do with my local patches.

This is from Geoff's job:
https://firefoxci.taskcluster-artifacts.net/TlxjGeYxQzanCCQJjgGPPg/0/public/logs/live_backing.log
There are about a dozen in that log.

Traceback: treeherder log and my local low shows basically the same
traceback. Some line numbers I see on my PC are changed due to debug output I
inserted locally.
Here is one from Geoff's job (the above URL)
```

[task 2023-01-25T00:14:27.545Z] 00:14:27     INFO - TEST-START | Shutdown
[task 2023-01-25T00:14:27.547Z] 00:14:27     INFO - Browser Chrome Test Summary
[task 2023-01-25T00:14:27.548Z] 00:14:27     INFO - Passed:  182
[task 2023-01-25T00:14:27.550Z] 00:14:27     INFO - Failed:  0
[task 2023-01-25T00:14:27.552Z] 00:14:27     INFO - Todo:    0
[task 2023-01-25T00:14:27.553Z] 00:14:27     INFO - Mode:    non-e10s
[task 2023-01-25T00:14:27.555Z] 00:14:27     INFO - *** End BrowserChrome Test Results ***
[task 2023-01-25T00:14:27.560Z] 00:14:27     INFO - GECKO(5202) | console.error:
[task 2023-01-25T00:14:27.564Z] 00:14:27     INFO - GECKO(5202) |   Message: TypeError: can't access property "URI", tab.folder is undefined
[task 2023-01-25T00:14:27.566Z] 00:14:27     INFO - GECKO(5202) |   Stack:
[task 2023-01-25T00:14:27.568Z] 00:14:27     INFO - GECKO(5202) |     persistTab@chrome://messenger/content/mailTabs.js:203:11
[task 2023-01-25T00:14:27.570Z] 00:14:27     INFO - GECKO(5202) | persistTab@chrome://messenger/content/tabmail.js:1288:32
[task 2023-01-25T00:14:27.571Z] 00:14:27     INFO - GECKO(5202) | persistTabs@chrome://messenger/content/tabmail.js:1338:31
[task 2023-01-25T00:14:27.573Z] 00:14:27     INFO - GECKO(5202) | getWindowStateForSessionPersistence@chrome://messenger/content/messenger.js:713:27
[task 2023-01-25T00:14:27.575Z] 00:14:27     INFO - GECKO(5202) | _saveState@resource:///modules/SessionStoreManager.jsm:175:32
[task 2023-01-25T00:14:27.577Z] 00:14:27     INFO - GECKO(5202) | observe@resource:///modules/SessionStoreManager.jsm:196:16
[task 2023-01-25T00:14:27.578Z] 00:14:27     INFO - GECKO(5202) | testsFinished@chrome://mochikit/content/browser-harness.xhtml:344:28
[task 2023-01-25T00:14:27.581Z] 00:14:27     INFO - GECKO(5202) | Tester_finish@chrome://mochikit/content/browser-test.js:535:10
[task 2023-01-25T00:14:27.582Z] 00:14:27     INFO - GECKO(5202) | nextTest/</</</</<@chrome://mochikit/content/browser-test.js:1006:22
[task 2023-01-25T00:14:27.583Z] 00:14:27     INFO - GECKO(5202) | nextTest/</shutdownCleanup/<@chrome://mochikit/content/browser-test.js:971:13
[task 2023-01-25T00:14:27.664Z] 00:14:27     INFO - GECKO(5202) | 1674605667663	Marionette	TRACE	Received observer notification quit-application
[task 2023-01-25T00:14:27.670Z] 00:14:27     INFO - GECKO(5202) | 1674605667669	Marionette	INFO	Stopped listening on port 2828
[task 2023-01-25T00:14:27.674Z] 00:14:27     INFO - GECKO(5202) | 1674605667674	Marionette	DEBUG	Marionette stopped listening
[task 2023-01-25T00:14:27.710Z] 00:14:27     INFO - GECKO(5202) | [Parent 5202, Compositor] WARNING: Possibly dropping task posted to updater thread: file /builds/worker/checkouts/gecko/gfx/layers/apz/src/APZUpdater.cpp:371
[task 2023-01-25T00:14:27.809Z] 00:14:27     INFO - GECKO(5202) | [2023-01-25T00:14:27Z WARN  webrender::device::gl] Missing optimized shader source for gpu_cache_update
[task 2023-01-25T00:14:27.993Z] 00:14:27     INFO - GECKO(5202) | [Parent 5202, Main Thread] WARNING: '!inner', file /builds/worker/checkouts/gecko/dom/ipc/jsactor/JSWindowActorProtocol.cpp:163
```

Attached is the output of the following command to show
which tests produced the errors.
```
egrep -a "(TEST_START|TEST_END|Message: TypeError: can't access property \"URI\", tab.folder is undefined)" log1526-mochitest.txt
```

To my surprise, many errors are printed between the tests(!?)
E.g.:
```
00:10.62 TEST_START: comm/mail/components/enterprisepolicies/tests/browser/hardware_acceleration/browser_policy_hardware_acceleration.js
00:10.95 TEST_END: Test OK. Subtests passed 0/1. Unexpected 1
00:18.98 GECKO(390025)	 Message: TypeError: can't access property "URI", tab.folder is undefined
00:21.59 TEST_START: comm/calendar/test/browser/recurrence/browser_customMinimonthCount.js
00:21.59 TEST_END: SKIP
```

On the other hand, some do occur in the tests, I think.

E.g.: timed out test.
```
01:41.53 TEST_START: comm/calendar/test/browser/eventDialog/browser_attendeesDialog.js
06:13.18 GECKO(390891)	 Message: TypeError: can't access property "URI", tab.folder is undefined
11:13.18 GECKO(390891)	 Message: TypeError: can't access property "URI", tab.folder is undefined
16:13.18 GECKO(390891)	 Message: TypeError: can't access property "URI", tab.folder is undefined
21:13.19 GECKO(390891)	 Message: TypeError: can't access property "URI", tab.folder is undefined
22:56.94 TEST_START: comm/calendar/test/browser/invitations/browser_attachedPublishEvent.js
```
Note: I just noticed the error got printed exactly five minutes
apart. Coincidence? I think timeout of 300 seconds somehow kicked in.

Another timed out test:
```
50:28.26 TEST_START: comm/mail/base/test/webextensions/browser_permissions_mozAddonManager.js
54:56.89 GECKO(397362)	 Message: TypeError: can't access property "URI", tab.folder is undefined
59:56.89 GECKO(397362)	 Message: TypeError: can't access property "URI", tab.folder is undefined
64:57.12 GECKO(397362)	 Message: TypeError: can't access property "URI", tab.folder is undefined
69:57.12 GECKO(397362)	 Message: TypeError: can't access property "URI", tab.folder is undefined
71:41.00 TEST_START: comm/mail/components/addrbook/test/browser/browser_cardDAV_init.js
```
The above errors do not see the strange 5-min separation in browser_attendeesDialog.js.


It is worth noting that the above two tests
- comm/calendar/test/browser/eventDialog/browser_attendeesDialog.js
- comm/mail/base/test/webextensions/browser_permissions_mozAddonManager.js
are worst offenders in terms of timeout.
I strongly suspect timeout and this undefined errors may be related.
I have a feeling there are some timing issues that either cause
the error "tab.folder is undefined" to occur, OR to triggered BY the
error condition. 

An excerpt  from the summary of my local log analyzer.
```
 ========================================
 TIMEOUT
 ========================================

01:41.52 TEST_END: Test OK. Subtests passed 29/29. Unexpected 0
01:41.53 TEST_START: comm/calendar/test/browser/eventDialog/browser_attendeesDialog.js
LONG PAUSE FOUND: 114.660000 seconds
LONG PAUSE FOUND: 119.500000 seconds
LONG PAUSE FOUND: 32.640000 seconds
LONG PAUSE FOUND: 86.870000 seconds
LONG PAUSE FOUND: 120.000000 seconds
LONG PAUSE FOUND: 92.650000 seconds
LONG PAUSE FOUND: 27.360000 seconds
LONG PAUSE FOUND: 272.640000 seconds
LONG PAUSE FOUND: 300.010000 seconds
LONG PAUSE FOUND: 96.180000 seconds
22:56.94 TEST_START: comm/calendar/test/browser/invitations/browser_attachedPublishEvent.js
22:59.55 TEST_END: Test OK. Subtests passed 2/2. Unexpected 0
--
50:28.26 TEST_END: Test OK. Subtests passed 55/55. Unexpected 0
50:28.26 TEST_START: comm/mail/base/test/webextensions/browser_permissions_mozAddonManager.js
LONG PAUSE FOUND: 29.840000 seconds
LONG PAUSE FOUND: 60.010000 seconds
LONG PAUSE FOUND: 23.220000 seconds
LONG PAUSE FOUND: 119.500000 seconds
LONG PAUSE FOUND: 32.730000 seconds
LONG PAUSE FOUND: 31.400000 seconds
LONG PAUSE FOUND: 55.380000 seconds
LONG PAUSE FOUND: 120.010000 seconds
LONG PAUSE FOUND: 92.720000 seconds
LONG PAUSE FOUND: 27.280000 seconds
LONG PAUSE FOUND: 272.940000 seconds
LONG PAUSE FOUND: 300.000000 seconds
LONG PAUSE FOUND: 95.750000 seconds

```