Skip to content

Commit

Permalink
Add tests for all other console methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Stegmaier committed Dec 11, 2022
1 parent d592911 commit 6e5cd0f
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 2 deletions.
61 changes: 61 additions & 0 deletions src/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,64 @@ window.triggerLoggingOutsideIframe = function () {
}
logOutsideIframe();
};

window.triggerConsoleAssert = function () {
console.assert(1, 2);
};

window.triggerConsoleCount = function () {
console.count();
console.count("abc");
};

window.triggerConsoleDir = function () {
console.dir({ a: { b: 1 } });
};

window.triggerDirXml = function () {
console.dirxml(document.createElement("div"));
};

window.triggerConsoleGroup = function () {
console.group("myGroup");
console.log("something");
console.groupEnd();
};

window.triggerConsoleGroupWithObject = function () {
const myObj = { a: 1 };
console.group(myObj);
console.log("something");
console.groupEnd();
};

window.triggerConsoleGroupCollapsed = function () {
const myObj = { a: 1 };
console.groupCollapsed(myObj);
console.log("something");
console.groupEnd();
};

window.triggerConsoleTable = function () {
console.table(["apples", "oranges", "bananas"]);
};

window.triggerConsoleTimeWithoutTimeEnd = function () {
console.time("myLabel");
};

window.triggerConsoleTimeWithObject = function () {
const myObj = { a: 1 };
console.time(myObj);
console.timeLog(myObj);
console.timeEnd(myObj);
};

window.triggerConsoleProfile = function () {
const myObj = { a: 1 };
console.profile(myObj);
};

window.triggerConsoleTimeStamp = function () {
console.timeStamp({ a: 1 });
};
16 changes: 14 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1>Test page for iframe error objects</h1>
<!-- <option value="log-hello-world-inside-iframe">Log "Hello World" INSIDE iframe -- (no leak)</option> -->
<option value="log-error-in-iframe">Log error INSIDE iframe -- (**CAUSES A LEAK**)</option>
<option value="log-function-in-iframe">Log function INSIDE iframe -- (**CAUSES A LEAK**)</option>
<option value="log-stringified-in-iframe">Log stringified function INSIDE iframe -- (TBD)</option>
<!-- <option value="log-stringified-in-iframe">Log stringified function INSIDE iframe -- (no leak)</option> -->
<option value="log-object-in-iframe">Log an object with properties INSIDE iframe -- (**CAUSES A LEAK**)</option>
<option value="throw-unhandled-error-in-iframe">Throw unhandled error INSIDE iframe -- (**CAUSES A LEAK**)</option>
<option value="throw-handled-error-in-iframe">Handle a thrown error INSIDE iframe -- (no leak)</option>
Expand All @@ -39,7 +39,19 @@ <h1>Test page for iframe error objects</h1>
<option value="trigger-logging-outside-iframe">Trigger logging newly-created error OUTSIDE the iframe from within the IFRAME -- (**CAUSES A LEAK**)</option>
<option value="trigger-logging-outside-iframe-object">Trigger logging newly-created non-error object OUTSIDE the iframe from within the IFRAME -- (no leak)</option>
<!-- <option value="trigger-logging-outside-iframe-error-created-outside-iframe">Trigger logging previously-created error OUTSIDE the iframe from within the IFRAME -- (no leak)</option> -->
<option value="trigger-throw-unhandled-error-outside-iframe">Throw an error OUTSIDE the iframe from within the IFRAME -- (**CAUSES A LEAK**)</option>
<!-- <option value="trigger-throw-unhandled-error-outside-iframe">Throw an error OUTSIDE the iframe from within the IFRAME -- (**CAUSES A LEAK**)</option> -->
<!-- <option value="trigger-console-assert-in-iframe">Call console assert INSIDE the iframe -- (**CAUSES A LEAK**)</option> -->
<!-- <option value="trigger-console-count-in-iframe">Call console count INSIDE the iframe -- (no leak)</option> -->
<!-- <option value="trigger-console-dir-in-iframe">Call console dir INSIDE the iframe -- (**CAUSES A LEAK**)</option> -->
<!-- <option value="trigger-console-dirxml-in-iframe">Call console dirxml INSIDE the iframe -- (**CAUSES A LEAK**)</option> -->
<!-- <option value="trigger-console-group-in-iframe">Call console group INSIDE the iframe -- (no leak)</option> -->
<!-- <option value="trigger-console-group-with-object-in-iframe">Call console group with an object INSIDE the iframe -- (**CAUSES A LEAK**)</option> -->
<!-- <option value="trigger-console-group-collapsed-in-iframe">Call console groupCollapsed INSIDE the iframe -- (**CAUSES A LEAK**)</option> -->
<!-- <option value="trigger-console-table-in-iframe">Call console table INSIDE the iframe -- (**CAUSES A LEAK**)</option> -->
<!-- <option value="trigger-console-time-without-end-in-iframe">Call console time without timeEnd INSIDE the iframe -- (no leak)</option> -->
<!-- <option value="trigger-console-time-with-object-in-iframe">Call console time with an object INSIDE the iframe -- (no leak)</option> -->
<!-- <option value="trigger-console-profile-in-iframe">Call console profile with an object INSIDE the iframe -- (no leak)</option> -->
<!-- <option value="trigger-console-timestamp-in-iframe">Call console timeStamp with an object INSIDE the iframe -- (no leak)</option> -->
</select>

<button id="add-iframe">Add iframe</button>
Expand Down
36 changes: 36 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,42 @@ function doPostAddingScenario(iframe) {
iframe.contentWindow.triggerThrowUnhandledError = throwUnhandledError;
iframe.contentWindow.triggerThrowUnhandledError();
return;
case "trigger-console-assert-in-iframe":
iframe.contentWindow.triggerConsoleAssert();
return;
case "trigger-console-count-in-iframe":
iframe.contentWindow.triggerConsoleCount();
return;
case "trigger-console-dir-in-iframe":
iframe.contentWindow.triggerConsoleDir();
return;
case "trigger-console-dirxml-in-iframe":
iframe.contentWindow.triggerConsoleDirXml();
return;
case "trigger-console-group-in-iframe":
iframe.contentWindow.triggerConsoleGroup();
return;
case "trigger-console-group-with-object-in-iframe":
iframe.contentWindow.triggerConsoleGroupWithObject();
return;
case "trigger-console-group-collapsed-in-iframe":
iframe.contentWindow.triggerConsoleGroupCollapsed();
return;
case "trigger-console-table-in-iframe":
iframe.contentWindow.triggerConsoleTable();
return;
case "trigger-console-time-without-end-in-iframe":
iframe.contentWindow.triggerConsoleTimeWithoutTimeEnd();
return;
case "trigger-console-time-with-object-in-iframe":
iframe.contentWindow.triggerConsoleTimeWithObject();
return;
case "trigger-console-profile-in-iframe":
iframe.contentWindow.triggerConsoleProfile();
return;
case "trigger-console-timestamp-in-iframe":
iframe.contentWindow.triggerConsoleTimeStamp();
return;
default:
alert("Invalid value for after-adding-iframe dropdown");
return;
Expand Down

0 comments on commit 6e5cd0f

Please sign in to comment.