Function window.console.log Trows Type Error: Invalid calling object While It Should Not

Confirmed Issue #14495220 • Assigned to edgedevtoolstri@microsoft.com

Details

Author
Vladimir K.
Created
Nov 2, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
  • Internet Explorer
Found in build #
16.16299
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

I need to print some debug information in a JS library I’m working on. I’m using
window.console.log, which I need to store in a variable for later usage. When DevTools panel is opened, everything works as expected, but when DevTools panel is closed, the following code throws an exception. I tested other browsers (Firefox, Safari, Chrome, Opera) and none of them behaves this way. I believe no exceptions should be thrown in any state (opened/closed) of DevTools.

// This code should not throw an exception when F12 DevTools are closed
const testBug = function () {
  let log = function () {};
  if (window.console && window.console.log) {
    log = window.console.log;
  }

  log('Bug not found!'); // EXCEPTION TROWN
}

try {
    testBug();
} catch (e) {
    alert(e.toString());
}

See also:

  1. Test case
  2. Source code of test

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “James M.”

      Changed Assigned To to “edgedevtoolstri@microsoft.com”

      Changed Status to “Confirmed”

    You need to sign in to your Microsoft account to add a comment.

    Sign in