Skip to content

Conversation

@metsma
Copy link
Contributor

@metsma metsma commented Nov 20, 2025

TypeError: can't access property "name", s.dataset is undefined

WE2-1143

Signed-off-by: Raul Metsma raul@metsma.ee

@miamibc
Copy link

miamibc commented Nov 20, 2025

Hello. Thank you, little bit better but still extension throws error.

GET https://krediidiraportid.ee/sitemap.xml [HTTP/1.1 200 OK 304ms]

XML Parsing Error: not well-formed
Location: 
Line Number 7, Column 33:
SyntaxError: An invalid or illegal string was specified [content.js:207:37](moz-extension://341d79c1-7e85-4808-b051-6a4ea0e25c20/content.js)
    injectPageScript moz-extension://341d79c1-7e85-4808-b051-6a4ea0e25c20/content.js:207
    <anonymous> moz-extension://341d79c1-7e85-4808-b051-6a4ea0e25c20/content.js:306
    <anonymous> moz-extension://341d79c1-7e85-4808-b051-6a4ea0e25c20/content.js:309
    #injectIntoIsolatedWorld resource://gre/modules/ExtensionContent.sys.mjs:683
    inject resource://gre/modules/ExtensionContent.sys.mjs:668
    injectInto resource://gre/modules/ExtensionContent.sys.mjs:518
    AsyncFunctionNext self-hosted:800
image

Solution can be - don't activate plugin on pages with mime type other than HTML.
Or, few more IFs and tests. Testpage for XML can be any sitemap: https://krediidiraportid.ee/sitemap.xml

@metsma metsma changed the title Workaround firefox warning Workaround firefox warning and inject if it is html or unknown Nov 20, 2025
@miamibc
Copy link

miamibc commented Nov 20, 2025

XML Parsing Error: not well-formed
Location: 
Line Number 7, Column 33:
SyntaxError: An invalid or illegal string was specified [content.js:214:37](moz-extension://239bb713-a580-45e0-966f-9c74664c44fc/content.js)
    injectPageScript moz-extension://239bb713-a580-45e0-966f-9c74664c44fc/content.js:214
    <anonymous> moz-extension://239bb713-a580-45e0-966f-9c74664c44fc/content.js:313
    <anonymous> moz-extension://239bb713-a580-45e0-966f-9c74664c44fc/content.js:316
    #injectIntoIsolatedWorld resource://gre/modules/ExtensionContent.sys.mjs:683
    inject resource://gre/modules/ExtensionContent.sys.mjs:668
    injectInto resource://gre/modules/ExtensionContent.sys.mjs:518
    AsyncFunctionNext self-hosted:800

I think your document type detection is not effective enough. I removed all your checks and added this one:

if (!document instanceof HTMLDocument) return;

Tested with

image

Detection works, but i don't understand what's going on after detection.

@miamibc
Copy link

miamibc commented Nov 20, 2025

Found reason.

instanceof gives true on XML docs, because XMLDocument and HTMLDocument both extends same type.

Changed verification to

		if (typeof( document ) !== 'HTMLDocument') {
			return;
		}

This is final version of injectPageScript function


    function injectPageScript() {
        if (typeof( document ) !== 'HTMLDocument') return;
        if (!document.querySelector("script[data-name='TokenSigning']")) {

            const s = document.createElement("script");
            s.type = "text/javascript";
            if (s.dataset) {
                s.dataset.name = "TokenSigning";
                s.dataset.by = "Web-eID extension";
            }
            else {
                s.setAttribute("data-name", "TokenSigning");
                s.setAttribute("data-by", "Web-eID extension");
            }
            if (browser.runtime.getManifest()["manifest_version"] >= 3) {
                s.src = browser.runtime.getURL("token-signing-page-script.js");
            }
            else {
                s.innerHTML = "(" + pageScript + ")();";
            }
            (document.head || document.documentElement).appendChild(s);
        }
    }

@metsma
Copy link
Contributor Author

metsma commented Nov 20, 2025

Maybe if (document.contentType !== "text/html") {

@miamibc
Copy link

miamibc commented Nov 20, 2025

I think

 if (typeof( document ) !== 'HTMLDocument') return;

is enough. Result will be the same, from information i know.

@metsma
Copy link
Contributor Author

metsma commented Nov 20, 2025

I think

 if (typeof( document ) !== 'HTMLDocument') return;

is enough. Result will be the same, from information i know.

This gives me 'object'

@miamibc
Copy link

miamibc commented Nov 20, 2025

Uh...
Here i found nice way to detect class name: https://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class

document.constructor.name => "HTMLDocument"

Let's change line 1 to

if (document.constructor.name !== 'HTMLDocument') return;

@miamibc
Copy link

miamibc commented Nov 21, 2025

Checked last artifact download URL: https://github.com/web-eid/web-eid-webextension/actions/runs/19536024038/artifacts/4626976308

Everything works correct on XML, HTML and text pages, no errors.

TypeError: can't access property "name", s.dataset is undefined

WE2-1143

Signed-off-by: Raul Metsma <raul@metsma.ee>
@miamibc
Copy link

miamibc commented Jan 16, 2026

Sorry, maybe it's time to merge? Or what we are waiting for? This is what i currently have installed from plugin repo:

Author Riigi Infosüsteemi Amet
Version 2.2.1
Last Updated 17 April 2025

@mrts
Copy link
Member

mrts commented Jan 16, 2026

We are waiting for testers' testing. We have a deliberate process and release cadence, the new version with this fix will be published to browser store during the next release cycle in end of Q1 or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants