Skip to content

Commit

Permalink
Add WPTest for CanvasRenderingContext2D.getContextAttributes()
Browse files Browse the repository at this point in the history
This CL adds a new WPTest for CanvasRenderingContext2D's
getContextAttributes(), see the bug for context.

Test: this a test exercised by all bots.
Bug: 919116, whatwg/html#2563
Change-Id: If60be98e1b885e14b4851a9a74c07ec77e63229e
Reviewed-on: https://chromium-review.googlesource.com/c/1395882
Reviewed-by: Fernando Serboncini <fserb@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#620426}
  • Loading branch information
yell0wd0g authored and chromium-wpt-export-bot committed Jan 7, 2019
1 parent eced296 commit 80e6afb
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions 2dcontext/context-attributes/getContextAttributes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>

var testScenarios = [
{testDescription: "Test default context creation attributes",
canvasContextAttributes: {},
expectedContextAttributes: {alpha : true}},
{testDescription: "Test context creation attributes alpha: true",
canvasContextAttributes: {alpha: true},
expectedContextAttributes: {alpha : true}},
{testDescription: "Test context creation attributes alpha: false",
canvasContextAttributes: {alpha: false},
expectedContextAttributes: {alpha : false}},
];

function runTestScenario(testScenario) {
var t = test(function() {
var canvas = document. createElement('canvas');
var ctx = canvas.getContext('2d', testScenario.canvasContextAttributes);
var contextAttributes = ctx.getContextAttributes();
assert_equals(contextAttributes.alpha,
testScenario.expectedContextAttributes.alpha);
}, testScenario.testDescription);
}

function runAllTests() {
for (var i = 0; i < testScenarios.length; i++)
runTestScenario(testScenarios[i]);
}

runAllTests();
</script>

0 comments on commit 80e6afb

Please sign in to comment.