Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URIMismatchError: Failed to construct URL from string "//www.googletagmanager.com/ns.html?id=xxx" relative to URL "about:blank". #1003

Closed
vjpr opened this issue Jul 25, 2023 · 3 comments · Fixed by #1012
Labels
bug Something isn't working

Comments

@vjpr
Copy link

vjpr commented Jul 25, 2023

Describe the bug

To Reproduce

Create a page with an iframe with a src with no protocol specified.

<noscript>
    <iframe
        src="//www.googletagmanager.com/ns.html?id=xxx"
        height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Device:

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@vjpr vjpr added the bug Something isn't working label Jul 25, 2023
@uovol
Copy link

uovol commented Aug 3, 2023

i have same issue

<iframe class="ifr" ref="refIframe" :src="`/iframe-item.html?id=${props.id}&t=1`" 
            sandbox="allow-scripts allow-same-origin" ></iframe>

error:

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Vitest caught 8 unhandled errors during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
URIMismatchError: Failed to construct URL from string "/iframe-item.html?id=88&t=1" relative to URL "about:blank".
 ❯ URL.set href [as href] node_modules/happy-dom/src/location/Location.ts:30:11
 ❯ new Window node_modules/happy-dom/src/window/Window.ts:473:22
 ❯ Function.loadPage node_modules/happy-dom/src/nodes/html-iframe-element/HTMLIFrameUtility.ts:26:36
 ❯ HTMLIFrameElement._connectToNode node_modules/happy-dom/src/nodes/html-iframe-element/HTMLIFrameElement.ts:182:22
 ❯ HTMLElement._connectToNode node_modules/happy-dom/src/nodes/node/Node.ts:422:19
 ❯ HTMLAnchorElement._connectToNode node_modules/happy-dom/src/nodes/node/Node.ts:422:19
 ❯ Function.insertBefore node_modules/happy-dom/src/nodes/node/NodeUtility.ts:193:19
 ❯ Function.insertBefore node_modules/happy-dom/src/nodes/element/ElementUtility.ts:185:16
 ❯ HTMLElement.insertBefore node_modules/happy-dom/src/nodes/element/Element.ts:404:25
 ❯ insert node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:13:12

This error originated in "components/user-login.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.

@uovol
Copy link

uovol commented Aug 3, 2023

My temporary solution is to add the full domain name to iframe's src.

capricorn86 added a commit that referenced this issue Aug 7, 2023
…g an iframe using a relative URL. The URL is now relative to the main document URL instead.
capricorn86 added a commit that referenced this issue Aug 7, 2023
…failed-to-construct-url-from-string-wwwgoogletagmanagercomnshtmlid=xxx-relative-to-url-aboutblank

#1003@patch: Fixes an issue where an exception was thrown when loadin…
@capricorn86
Copy link
Owner

Thank you for reporting @vjpr and @uovol! 🙂

There is a fix released now:
https://github.com/capricorn86/happy-dom/releases/tag/v10.8.1

Note that you need to set a URL on the main document in order for the iframe URL to be relative to it. The main document defaults to "about:blank" if no URL has been set (see #868).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants