зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1003380 - Implementation + test for createPattern with a broken image. r=bas
This commit is contained in:
Родитель
13a5c83bb6
Коммит
b84c725ce4
|
@ -1490,7 +1490,13 @@ CanvasRenderingContext2D::CreatePattern(const HTMLImageOrCanvasOrVideoElement& e
|
|||
return pat.forget();
|
||||
}
|
||||
} else if (element.IsHTMLImageElement()) {
|
||||
htmlElement = &element.GetAsHTMLImageElement();
|
||||
HTMLImageElement* img = &element.GetAsHTMLImageElement();
|
||||
if (img->IntrinsicState().HasState(NS_EVENT_STATE_BROKEN)) {
|
||||
error.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
htmlElement = img;
|
||||
} else {
|
||||
htmlElement = &element.GetAsHTMLVideoElement();
|
||||
}
|
||||
|
|
|
@ -213,3 +213,4 @@ skip-if = (buildapp == 'b2g' && toolkit != 'gonk')
|
|||
[test_toDataURL_parameters.html]
|
||||
[test_windingRuleUndefined.html]
|
||||
[test_2d.fillText.gradient.html]
|
||||
[test_createPattern_broken.html]
|
||||
|
|
|
@ -15108,7 +15108,7 @@ var img = new Image();
|
|||
todo(img.complete === false, "img.complete === false");
|
||||
var _thrown = undefined; try {
|
||||
ctx.createPattern(img, 'repeat');
|
||||
} catch (e) { _thrown = e }; todo(_thrown && _thrown.name == "InvalidStateError" && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw InvalidStateError");
|
||||
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "InvalidStateError" && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw InvalidStateError");
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for createPattern with a broken image</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||
<script type="application/javascript" src="file_drawWindow_common.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
window.addEventListener("load", function(){
|
||||
var _thrown = undefined;
|
||||
|
||||
try{
|
||||
var img = document.getElementById('broken.png');
|
||||
var ctx = document.getElementById('c').getContext('2d');
|
||||
var p = ctx.createPattern(img, 'repeat');
|
||||
} catch (e) {
|
||||
_thrown = e
|
||||
};
|
||||
|
||||
ok(_thrown && _thrown.name == "InvalidStateError" && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw InvalidStateError");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="c" class="output" width="100" height="50"></canvas>
|
||||
<img src="/images/broken.png" id="broken.png" class="resource"/>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче