-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1580000 [wpt PR 18945] - Compute img aspect ratio from width and …
…height HTML attributes, a=testonly Automatic update from web-platform-tests Compute img aspect ratio from width and height HTML attributes As per this intent to implement: https://groups.google.com/a/chromium.org/forum/?fromgroups#!topic/blink-dev/hbhKRuBzZ4o Spec: WICG/intrinsicsize-attribute#16 Bug: 979891 Change-Id: I0f9ffa1584fa12a41393ef05daffb7238c97e990 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1790472 Commit-Queue: Christian Biesinger <cbiesingerchromium.org> Reviewed-by: Emilio Cobos Álvarez <emiliochromium.org> Auto-Submit: Christian Biesinger <cbiesingerchromium.org> Cr-Commit-Position: refs/heads/master{#699465} -- wpt-commits: 86ff86de45a67eccc781b84f50ab261c18aad5cf wpt-pr: 18945 UltraBlame original commit: e8962724f6cc584847fedccd8c0912b6bd00dab6
- Loading branch information
Showing
3 changed files
with
918 additions
and
17 deletions.
There are no files selected for viewing
253 changes: 253 additions & 0 deletions
253
...ing/replaced-elements/attributes-for-embedded-content-and-images/canvas-aspect-ratio.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
< | ||
! | ||
doctype | ||
html | ||
> | ||
< | ||
title | ||
> | ||
Canvas | ||
width | ||
and | ||
height | ||
attributes | ||
are | ||
used | ||
to | ||
infer | ||
aspect | ||
- | ||
ratio | ||
< | ||
/ | ||
title | ||
> | ||
< | ||
script | ||
src | ||
= | ||
" | ||
/ | ||
resources | ||
/ | ||
testharness | ||
. | ||
js | ||
" | ||
> | ||
< | ||
/ | ||
script | ||
> | ||
< | ||
script | ||
src | ||
= | ||
" | ||
/ | ||
resources | ||
/ | ||
testharnessreport | ||
. | ||
js | ||
" | ||
> | ||
< | ||
/ | ||
script | ||
> | ||
< | ||
style | ||
> | ||
canvas | ||
{ | ||
width | ||
: | ||
100 | ||
% | ||
; | ||
max | ||
- | ||
width | ||
: | ||
100px | ||
; | ||
height | ||
: | ||
auto | ||
; | ||
} | ||
< | ||
/ | ||
style | ||
> | ||
< | ||
body | ||
> | ||
< | ||
script | ||
> | ||
let | ||
t | ||
= | ||
async_test | ||
( | ||
" | ||
Canvas | ||
width | ||
and | ||
height | ||
attributes | ||
are | ||
used | ||
to | ||
infer | ||
aspect | ||
- | ||
ratio | ||
" | ||
) | ||
; | ||
function | ||
assert_ratio | ||
( | ||
img | ||
expected | ||
) | ||
{ | ||
let | ||
epsilon | ||
= | ||
0 | ||
. | ||
001 | ||
; | ||
assert_approx_equals | ||
( | ||
parseInt | ||
( | ||
getComputedStyle | ||
( | ||
img | ||
) | ||
. | ||
width | ||
10 | ||
) | ||
/ | ||
parseInt | ||
( | ||
getComputedStyle | ||
( | ||
img | ||
) | ||
. | ||
height | ||
10 | ||
) | ||
expected | ||
epsilon | ||
) | ||
; | ||
} | ||
/ | ||
/ | ||
Create | ||
and | ||
append | ||
a | ||
new | ||
canvas | ||
and | ||
immediately | ||
check | ||
the | ||
ratio | ||
. | ||
t | ||
. | ||
step | ||
( | ||
function | ||
( | ||
) | ||
{ | ||
var | ||
canvas | ||
= | ||
document | ||
. | ||
createElement | ||
( | ||
" | ||
canvas | ||
" | ||
) | ||
; | ||
canvas | ||
. | ||
setAttribute | ||
( | ||
" | ||
width | ||
" | ||
" | ||
250 | ||
" | ||
) | ||
; | ||
canvas | ||
. | ||
setAttribute | ||
( | ||
" | ||
height | ||
" | ||
" | ||
100 | ||
" | ||
) | ||
; | ||
document | ||
. | ||
body | ||
. | ||
appendChild | ||
( | ||
canvas | ||
) | ||
; | ||
/ | ||
/ | ||
Canvases | ||
always | ||
use | ||
the | ||
aspect | ||
ratio | ||
from | ||
their | ||
surface | ||
size | ||
. | ||
assert_ratio | ||
( | ||
canvas | ||
2 | ||
. | ||
5 | ||
) | ||
; | ||
t | ||
. | ||
done | ||
( | ||
) | ||
; | ||
} | ||
) | ||
; | ||
< | ||
/ | ||
script | ||
> |
Oops, something went wrong.