Bug: JavaScript error: resource:///modules/imThemes.jsm, line 740: SecurityError: The operation is insecure.
Status: RESOLVED
Priority: --
Resolution: DUPLICATE
Created: 2020-05-16 09:42:34+00:00
Resolved: 2024-06-07 15:58:45+00:00

During local mochitest execution with FULL DEBUG version of TB under Debian
GNU/Linux 64-bit, I saw the following error.

    6:	JavaScript error: resource:///modules/imThemes.jsm, line 740: SecurityError: The operation is insecure.

I think the error is architecture neutral and so I set it to ALL.

The source code in question is as follows.
https://searchfox.org/comm-central/source/chat/modules/imThemes.jsm#740

It is part of addCSS().:

```
  HTML += '<div id="Chat" aria-live="polite"></div>';
  HTML += replaceKeywordsInHTML(
    aTheme.html.footer,
    headerFooterReplacements,
    aConv
  );
  aDoc.open();	 <====
  aDoc.write(HTML + "</body></html>");
  aDoc.close();
  aDoc.defaultView.convertTimeUnits = DownloadUtils.convertTimeUnits;
}
```
I think javaScript() is trying to warn that the opening aDoc() is
  dangerous (?) Maybe we are creating a dynamically created HTML
  documents which we have no control over (based on user/remote
  input???). I have no idea.

The errors happen in the following tests.

```
46:46.42 TEST_START: comm/mail/components/preferences/test/browser/browser_chat.js
46:46.42 INFO Entering test bound
47:02.74 GECKO(814918) JavaScript error: resource:///modules/imThemes.jsm, line 740: SecurityError: The operation is insecure.
47:02.74 GECKO(814918) JavaScript error: resource:///modules/imThemes.jsm, line 740: SecurityError: The operation is insecure.
47:02.89 INFO Console message: [JavaScript Error: "SecurityError: The operation is insecure." {file: "resource:///modules/imThemes.jsm" line: 740}]
47:02.89 INFO Console message: [JavaScript Error: "SecurityError: The operation is insecure." {file: "resource:///modules/imThemes.jsm" line: 740}]
47:06.58 GECKO(814918) JavaScript error: resource:///modules/imThemes.jsm, line 740: SecurityError: The operation is insecure.
47:06.58 GECKO(814918) JavaScript error: resource:///modules/imThemes.jsm, line 740: SecurityError: The operation is insecure.
47:06.84 INFO Console message: [JavaScript Error: "SecurityError: The operation is insecure." {file: "resource:///modules/imThemes.jsm" line: 740}]
47:06.85 INFO Console message: [JavaScript Error: "SecurityError: The operation is insecure." {file: "resource:///modules/imThemes.jsm" line: 740}]
47:10.50 GECKO(814918) JavaScript error: resource:///modules/imThemes.jsm, line 740: SecurityError: The operation is insecure.
47:10.50 GECKO(814918) JavaScript error: resource:///modules/imThemes.jsm, line 740: SecurityError: The operation is insecure.
47:10.51 INFO Leaving test bound
47:10.68 INFO Console message: [JavaScript Error: "SecurityError: The operation is insecure." {file: "resource:///modules/imThemes.jsm" line: 740}]
47:10.68 INFO Console message: [JavaScript Error: "SecurityError: The operation is insecure." {file: "resource:///modules/imThemes.jsm" line: 740}]
47:10.71 TEST_END: Test OK. Subtests passed 186/186. Unexpected 0
```
The above is created by the following command.:
```
egrep "(TEST_START|TEST_END|Entering test|Leaving test|operation is insecure)" /FF-NEW/log1222-mochitest.txt
```

I am attaching an excerpt from my local mochitest execution with FULL
DEBUG version of TB.
The log is more verbose than normal execution because I have added
local debug dump.

The log indicates there are OTHER errors that may cause this bug to
appear.
I think someone needs to look into this test in depth.