Image object type lost when accessing other page's element, causing canvas drawImage TypeMismatch error!

Issue #5979222 • Assigned to Li-Hsin H.


Dec 28, 2015
This issue is public.
Reported by 3 people

Sign in to watch or report this issue.

Steps to reproduce


Repro Steps:

1.Create a.html with an img id=srcimg.
2.Write JS code in a.html to open b.html using
3.Create b.html with a canvas id=cv.
4.Write JS in b.html. get srcimg object from a.html using var img=window.opener.document.getElementById(“srcimg”).
5.Write JS immedialtely as this:
var c = document.getElementById(“cv”)
var ctx = c.getContext(“2d”);
ctx.drawImage(img, 0,0);

  1. Open Develop windows and you’ll find IE issues TYPE_MISMATCH_ERROR.
  2. By debugging, you’ll find srcimg is HTMLImageElement but type of object what img got is DispHTMLImg. This is why the error caused. Other brand’s browsers have no such problem.
  3. The workaround is in my post on Stackoverflow website.
  4. I am particularly curious why IE’s VM do this wrapping? Is it because of security issue. But I think the drawImage API developer of MS IE team isn’t aware this wrapping behavior.

Expected Results:

When I use JS to access my opener’s image object (type is HTMLImageElement), the object type will be wrapped as DispHTMLImg. When we apply it to be first argument in HTML5 Canvas drawImage API, it will cause TYPE_MISMATCH_ERROR. Only IE has this problem. I have to use some workaround to deal with this problem. This bug has caused a lot of pains to tremendous Web developers. Besides fixing this bug in Edge, can MS provide a patch for at least IE 10 or up?

Actual Results:

Dev Channel specific:



0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Mara P.”

      Changed Assigned To to “Christian F.”

      Changed Assigned To from “Christian F.” to “Li-Hsin H.”

    • This problem is happening in the latest Edge, and the workaround doesn’t appear to work any more. Any suggestions?

    • Have same issue. Because of it we can’t support Ie 11 and Edge since it forces us to create completely new solution for cases we draw smth in opened window

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

    Sign in