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

Unified Diff: LayoutTests/fast/canvas/script-tests/canvas-frameless-document-text.js

Issue 186063003: Prevent crash when calling text-related methods on a 2D canvas in a frame-less document. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed test Created 6 years, 10 months 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
Index: LayoutTests/fast/canvas/script-tests/canvas-frameless-document-text.js
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-frameless-document-text.js b/LayoutTests/fast/canvas/script-tests/canvas-frameless-document-text.js
new file mode 100644
index 0000000000000000000000000000000000000000..c93131b98738f18c5ad7e008937304019acc2cfd
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/canvas-frameless-document-text.js
@@ -0,0 +1,20 @@
+description("This verifies that the browser does not crash when drawing text to a canvas in a frame-less document.");
+
+// It is not clear frome the spec whether this is supposed to work and how.
+// Therefore, we do not validate the rendering results. We just make sure
+// this does not crash the browser.
+var canvas1 = document.createElement('canvas');
+var ctx1 = canvas1.getContext('2d');
+var htmlDoc = document.implementation.createHTMLDocument('', '', null);
+htmlDoc.adoptNode(canvas1);
+var canvas2 = htmlDoc.createElement('canvas');
+var ctx2 = canvas2.getContext('2d');
+
+ctx1.font = 'italic 30px Arial';
+ctx2.font = 'italic 30px Arial';
+ctx1.fillText('Text1', 0, 30);
+ctx2.fillText('Text1', 0, 30);
+ctx1.strokeText('Text2', 0, 60);
+ctx2.strokeText('Text2', 0, 60);
+ctx1.measureText('Text3');
+ctx2.measureText('Text3');

Powered by Google App Engine
This is Rietveld 408576698