<!doctype html>
<meta charset="utf-8">
<title>data URL image</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
setup({ single_test: true });

var c = document.createElement("canvas"),
    con = c.getContext("2d"),
    img = document.createElement("img")
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAA+UlEQVR4nO3RoRHAQBDEsOu/6YR+B2sgIO4Z3919pMwDMCRtHoAhafMADEmbB2BI2jwAQ9LmARiSNg/AkLR5AIakzQMwJG0egCFp8wAMSZsHYEjaPABD0uYBGJI2D8CQtHkAhqTNAzAkbR6AIWnzAAxJmwdgSNo8AEPS5gEYkjYPwJC0eQCGpM0DMCRtHoAhafMADEmbB2BI2jwAQ9LmARiSNg/AkLR5AIakzQMwJG0egCFp8wAMSZsHYEjaPABD0uYBGJI2D8CQtHkAhqTNAzAkbR6AIWnzAAxJmwdgSNo8AEPS5gEYkjYPwJC0eQCGpM0DMCRtHsDjB5K06yueJFXJAAAAAElFTkSuQmCC"
img.onload = () => {
  con.drawImage(img, 0, 0)
  var data = con.getImageData(0, 0, 10, 10) // should not throw as data URLs are same-origin
  for(var i = 0; i < data.data.length; i++) {
    var expected = ((i+1) % 4 == 0) ? 255 : 0
    assert_equals(data.data[i], expected)
  }
  c.toDataURL() // shouldn't throw either
  done()
}
</script>
