Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap.html

Issue 1532473002: Add a origin clean flag in ImageBitmap class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: using promise chain in layout test Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap.html b/third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap.html
index b5b56246330c1651dda1cd7b99ac56b1721b2f14..c3d7350bcaaba9afdb0c8f9b4cd4d03eab8e87bd 100644
--- a/third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap.html
+++ b/third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap.html
@@ -3,44 +3,73 @@
<body>
<script src="/js-test-resources/js-test.js"></script>
<script>
-description("The image bitmap factories should throw exceptions on cross-origin access.");
+description("The image bitmap factories should not throw exceptions on cross-origin access.");
window.jsTestIsAsync = true;
var reason;
-function shouldBeRejected(promise, message) {
- return promise.then(function() {
- testFailed('Resolved unexpectedly: ' + message);
+function shouldBeAcceptedAndTainted(promise, message) {
+ return promise.then(function(imageBitmap) {
+ testPassed('Resolved as expected: ' + message);
+ shouldBeTainted(imageBitmap);
}, function(e) {
reason = e;
- testPassed('Rejected as expected: ' + message);
+ testFailed('Rejected unexpectedly: ' + message);
shouldBeTrue('reason instanceof Error');
debug(e);
});
}
-Promise.resolve().then(function() {
- return new Promise(function(resolve, reject) {
- var image = document.createElement('img');
- image.addEventListener('load', resolve.bind(undefined, image));
- image.src = 'http://localhost:8080/security/resources/abe.png';
- document.body.appendChild(image);
- }).then(function(image) {
- return shouldBeRejected(createImageBitmap(image, 0, 0, 10, 10), 'image');
- });
-}).then(function() {
- return new Promise(function(resolve, reject) {
- var video = document.createElement('video');
- video.src = 'http://localhost:8080/media/resources/load-video.php?name=test.ogv&amp;type=video/ogv';
- video.addEventListener('playing', resolve.bind(undefined, video));
- document.body.appendChild(video);
- video.play();
- }).then(function(video) {
- return shouldBeRejected(createImageBitmap(video, 0, 0, 10, 10), 'video');
+function shouldBeTainted(imageBitmap) {
+ var canvas = document.createElement("canvas");
+ canvas.width = 10;
+ canvas.height = 10;
+ var context = canvas.getContext("2d");
+ context.drawImage(imageBitmap, 0, 0, 10, 10);
+ try {
+ var imageData = context.getImageData(0, 0, 10, 10);
+ testFailed("FAIL: ImageBitmap is not tainted.");
Justin Novosad 2016/01/04 20:45:51 No need for "FAIL:" because testFailed already add
xidachen 2016/01/05 16:06:44 Acknowledged.
+ } catch (e) {
+ testPassed("PASS: ImageBitmap is tainted. Threw error: " + e);
Justin Novosad 2016/01/04 20:45:51 No need for "PASS:". Notice the lines starting in
xidachen 2016/01/05 16:06:44 Acknowledged.
+ }
+}
+
+var image = document.createElement('img');
+image.src = 'http://localhost:8080/security/resources/abe.png';
+var video = document.createElement('video');
+video.src = 'http://localhost:8080/media/resources/load-video.php?name=test.ogv&amp;type=video/ogv';
+
+image.addEventListener('load', function() {
+ document.body.appendChild(image);
+ shouldBeAcceptedAndTainted(createImageBitmap(image, 0, 0, 10, 10), 'image')
+.then(function() {
+ var canvas = document.createElement("canvas");
+ canvas.width = 10;
+ canvas.height = 10;
+ var context = canvas.getContext("2d");
+ // taint the canvas
+ context.drawImage(image, 0, 0, 10, 10);
+ shouldBeAcceptedAndTainted(createImageBitmap(canvas, 0, 0, 10, 10), 'canvas')
+.then(function() {
+ createImageBitmap(image).then(imageBitmap => {
+ shouldBeAcceptedAndTainted(createImageBitmap(imageBitmap, 0, 0, 10, 10), 'imageBitmap').
+then(function() {
Justin Novosad 2016/01/04 20:45:51 inconsistent line wrapping ("then" vs. ".then")
xidachen 2016/01/05 16:06:44 Acknowledged.
+ document.body.appendChild(video);
+ video.play();
+ video.addEventListener('playing', function() {
+ shouldBeAcceptedAndTainted(createImageBitmap(video, 0, 0, 10, 10), 'video').then(finishJSTest, finishJSTest);
Justin Novosad 2016/01/04 20:45:51 The rejection handlers should print a failure mess
xidachen 2016/01/05 16:06:44 Acknowledged.
});
-}).catch(function(e) {
- testFailed('Unexpected rejection: ' + e);
-}).then(finishJSTest, finishJSTest);
+}, function() {
Justin Novosad 2016/01/04 20:45:51 "function() { myFunction(); }" => "myFunction"
xidachen 2016/01/05 16:06:44 Acknowledged.
+ finishJSTest();
+});
+});
+}, function() {
+ finishJSTest();
+});
+}, function() {
+ finishJSTest();
+});
+});
</script>
</body>
</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698