Bug: Pop3d.js fails during many xpcshell tests
Status: RESOLVED
Priority: --
Resolution: DUPLICATE
Created: 2022-05-23 05:55:53+00:00
Resolved: 2022-05-23 06:09:19+00:00

I am testing my  patches of TB locally under Debian GNU/Linux.
It could be linux-specific, but it may be more like problems for non-windows platforms.

Suddenly I got a series of errors during xpcshell-test that are triggered by an error in Pop3d.js.: turns out this is used as part of fakeserver (pop3).
I don't believe It should not begin to fault due to my patch.
(This error seems to be caused by changes in the last few days. I kept M-C/C-C tree for a few days to track down a bug caused by patches.  After the bulk of the error were fixed, I updated my local M-C/C-C tree in the last 24 hours and then suddenly I notice these errors.)

As a matter of fact, the same errors are now seen in OTHER PEOPLE's job (without my patch, of course)
For example, geoff's job:
Mon, May 23, 07:47:51
https://treeherder.mozilla.org/jobs?repo=comm-central&selectedTaskRun=cgAqL_wBRnGUcR5oM3sWWw.0&revision=f83e0ba151d33ad1e196a8be7c0be99ef04436aa

Look at
Linux 18.04 x64 WebRender debug
its X1, X2, X3 and X4 tests.
There are many tests that fail due to an error returned from Pop3d.js
and its error code is
(NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIFile.appendRelativePath]
Suddenly, the function began failing.
The errors share the same backtrace.:

  NS_ERROR_FILE_UNRECOGNIZED_PATH: Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIFile.appendRelativePath]
  readFile@resource://testing-common/mailnews/Pop3d.jsm:58:10
  addMessage@resource://testing-common/mailnews/Pop3d.jsm:93:41
  setMessages@resource://testing-common/mailnews/Pop3d.jsm:99:14
  POP3Pump.prototype._testNext@../../../resources/POP3pump.js:216:18

I inserted a dump in my local copy to see what kind of file path was causing an issue, and they all seem to be a relative path as in the following.
(The line numbers are different due to my dump code.)
grep Pop3d.jsm log1432-xpcshell-38.txt | grep Error
```
 0:26.22 ERROR Error: Cannot find file named ../../../data/draft1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/draft1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:52.03 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:52.56 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:09.12 ERROR Error: Cannot find file named ../../../data/mime-torture at resource://testing-common/mailnews/Pop3d.jsm:67
 0:10.98 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:24.03 ERROR Error: Cannot find file named ../../../data/mime-torture at resource://testing-common/mailnews/Pop3d.jsm:67
 0:25.81 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:26.15 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:26.48 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:26.82 ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:28.28 ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:28.61 ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:28.98 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:29.33 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:32.73 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:33.76 ERROR Error: Cannot find file named ../../../data/draft1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:38.08 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:50.67 ERROR Error: Cannot find file named ../../../data/mime-torture at resource://testing-common/mailnews/Pop3d.jsm:67
 0:52.81 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:53.15 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:53.49 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:53.84 ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:55.39 ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:55.74 ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:56.11 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:56.46 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 1:00.30 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 1:01.45 ERROR Error: Cannot find file named ../../../data/draft1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/mime-torture at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/mime-torture at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/draft1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/mime-torture at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail10 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/draft1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:01.98 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:02.33 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
 0:02.71 ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67
ERROR Error: Cannot find file named ../../../data/bugmail1 at resource://testing-common/mailnews/Pop3d.jsm:67

```

I took a look at Pop3d.jsm and found that if I let the code to handle the appending
ALWAYS in the legacy windows method, the code works again (!?)
https://searchfox.org/comm-central/source/mailnews/test/fakeserver/Pop3d.jsm#41
```
  if ("@mozilla.org/windows-registry-key;1" in Cc) {   <==== I modified this to if (true) {
    // Windows doesn't allow '..' in appendRelativePath,
    // so we'll have to do this the long way.
    if (fileName.includes("/")) {
      let parts = fileName.split("/");
      for (let part of parts) {
        if (part == "..") {
          file = file.parent;
        } else {
          file.append(part);
        }
      }
    } else {
      file.append("data");
      file.append(fileName);
    }
  } else {    <--- the non-windows code after this line experienced the error.
```
With this change, I could get the xpcshell test to proceed as before.
But given that file append and friends are used by many JS scripts, I think we should investigate.