Skip to content

Commit

Permalink
Test logging and object created outside the iframe.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Stegmaier committed Nov 30, 2022
1 parent 93d57e4 commit 086645b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h1>Test page for iframe error objects</h1>
<option value="override-console-error-in-iframe-broken">Log error INSIDE iframe, with BROKEN console patch -- (**CAUSES A LEAK**)</option>
<option value="override-console-error-in-iframe-fixed">Log error INSIDE iframe, with FIXED console patch -- (no leak)</option>
<option value="trigger-logging-outside-iframe">Trigger logging error OUTSIDE the iframe from within the IFRAME, with FIXED console patch -- (**CAUSES A LEAK**)</option>
<option value="trigger-logging-outside-iframe-object-created-outside-iframe">Trigger logging error OUTSIDE the iframe from within the IFRAME, with FIXED console patch, error object created OUTSIDE iframe -- (no leak)</option>
</select>

<button id="add-iframe">Add iframe</button>
Expand Down
14 changes: 13 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ function doPostAddingScenario(iframe) {
iframe.contentWindow.logOutsideIframe = logOutsideIframe;
iframe.contentWindow.triggerLoggingOutsideIframe()
return;
case "trigger-logging-outside-iframe-object-created-outside-iframe":
overrideConsoleForIframeFixed(iframe.contentWindow);
iframe.contentWindow.logOutsideIframe = logOutsideIframeObjectCreatedOutsideIframe;
iframe.contentWindow.triggerLoggingOutsideIframe()
return;
default:
alert("Invalid value for after-adding-iframe dropdown");
return;
Expand Down Expand Up @@ -228,8 +233,15 @@ function overrideConsoleForIframeFixed(iframeWindow) {
};
}


function logOutsideIframe() {
console.error(new Error("This error was created and logged outside the <iframe>"));
console.error(new Error("This error was logged outside the <iframe>"));
}

const errorCreatedOutsideIframe = new Error("This error object was CREATED outside the iframe context");

function logOutsideIframeObjectCreatedOutsideIframe() {
console.error()
}

/**
Expand Down

0 comments on commit 086645b

Please sign in to comment.