Skip to content

Commit

Permalink
Bug 1830320 [wpt PR 39730] - FLEDGE: Enable screen height as unit and…
Browse files Browse the repository at this point in the history
… pure numbers input for ad size., a=testonly

Automatic update from web-platform-tests
FLEDGE: Enable screen height as unit and pure numbers input for ad
size.

Currently, for generateBid() and joinAdInterestGroup(), the supported
ad size units are
* "px": pixel
* "sw": screen width

This CL adds the unit:
* "sh": screen height

The parser is also updated to support parsing pure numbers as pixels.
For example, "100" is parsed as 100 pixels.

A regular expression is used to match the input, and capture the
sub-patterns for value and unit.
^\s*((?:0|(?:[1-9][0-9]*))(?:\.[0-9]+)?)(px|sw|sh)?\s*$

It basically means we match
1. Zero or more leading spaces.
2. Numbers, with optionally decimal point and digits. No leading space, cannot begin with zero, non-negative. (Sub-pattern captured)
3. Immediately followed by an unit which can be one of "px", "sw" or "sh", or the unit can be ignored entirely.
entirely. (Sub-pattern captured)
4. Zero or more trailing spaces.

Bug: http://b/239866637

See Turtledove issue: WICG/turtledove#312
See Turtledove PR: WICG/turtledove#417

Change-Id: I336055ff3dd635dcdfd78999d0cb5972569f5ac1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4402817
Commit-Queue: Xiaochen Zhou <xiaochenzh@chromium.org>
Reviewed-by: Garrett Tanzer <gtanzer@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1137102}

--

wpt-commits: 673c0db073476e169caf04637dd900ea56ce08ce
wpt-pr: 39730
  • Loading branch information
xiaochen-z authored and moz-wptsync-bot committed May 21, 2023
1 parent c177b7f commit 33a9ac9
Showing 1 changed file with 0 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@
}

// Type error cases.
promise_test(async () => { return checkSyntaxError('299', '72'); }, '299 x 72');
promise_test(async () => { return checkSyntaxError('299px', '72'); }, '299px x 72');
promise_test(async () => { return checkSyntaxError('299', '72px'); }, '299 x 72px');
promise_test(async () => { return checkSyntaxError('-299px', '72px'); }, '-299px x 72px');
promise_test(async () => { return checkSyntaxError('299px', '-72px'); }, '299px x -72px');
promise_test(async () => { return checkSyntaxError('0px', '0px'); }, '0px x 0px');
Expand Down

0 comments on commit 33a9ac9

Please sign in to comment.