Visitar URL original
Implement QueuingStrategies in C++ · web-platform-tests/wpt@4dbc86f · GitHub
Skip to content

Commit 4dbc86f

Browse files
riceachromium-wpt-export-bot
authored andcommitted
Implement QueuingStrategies in C++
Implement CountQueuingStrategy and ByteLengthQueuingStrategy in C++. Implementing in WebIDL leads to some changes in semantics: 1. highWaterMark is now a getter on the prototype rather than an property on each object. This is because adding properties directly on objects is not usual practice in WebIDL, and is problematic to implement in Blink. 2. size() is now a function returned by a getter. This is because a methods in WebIDL must be called with |this| set to a valid object of the appropriate type, but size() is called with |this| set to undefined. See whatwg/streams#1005 for more discussion. These aren't expected to change behaviour of code in the wild, but the count-queuing-strategy.any.js and byte-length-queuing-strategy.js tests detect it. Also add tests that subclassing of CountQueuingStrategy and ByteLengthQueuingStrategyworks works properly. A previous iteration of this change broke it. Bug: 981333 Change-Id: Ifc18a469a58f73d54563ca549a1c8db0e001303b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692108 Reviewed-by: Yutaka Hirano <yhirano@chromium.org> Commit-Queue: Adam Rice <ricea@chromium.org> Cr-Commit-Position: refs/heads/master@{#679897}
1 parent 0404dd3 commit 4dbc86f

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

‎streams/byte-length-queuing-strategy.any.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,26 @@ test(() => {
107107
'ByteLengthQueuingStrategy.name must be "ByteLengthQueuingStrategy"');
108108

109109
}, 'ByteLengthQueuingStrategy.name is correct');
110+
111+
class SubClass extends ByteLengthQueuingStrategy {
112+
size() {
113+
return 2;
114+
}
115+
116+
subClassMethod() {
117+
return true;
118+
}
119+
}
120+
121+
test(() => {
122+
123+
const sc = new SubClass({highWaterMark: 77});
124+
assert_equals(sc.constructor.name, 'SubClass',
125+
'constructor.name should be correct');
126+
assert_equals(sc.highWaterMark, 77,
127+
'highWaterMark should come from the parent class');
128+
assert_equals(sc.size(), 2,
129+
'size() on the subclass should override the parent');
130+
assert_true(sc.subClassMethod(), 'subClassMethod() should work');
131+
132+
}, 'subclassing ByteLengthQueuingStrategy should work correctly');

‎streams/count-queuing-strategy.any.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,26 @@ test(() => {
106106
'CountQueuingStrategy.name must be "CountQueuingStrategy"');
107107

108108
}, 'CountQueuingStrategy.name is correct');
109+
110+
class SubClass extends CountQueuingStrategy {
111+
size() {
112+
return 2;
113+
}
114+
115+
subClassMethod() {
116+
return true;
117+
}
118+
}
119+
120+
test(() => {
121+
122+
const sc = new SubClass({highWaterMark: 77});
123+
assert_equals(sc.constructor.name, 'SubClass',
124+
'constructor.name should be correct');
125+
assert_equals(sc.highWaterMark, 77,
126+
'highWaterMark should come from the parent class');
127+
assert_equals(sc.size(), 2,
128+
'size() on the subclass should override the parent');
129+
assert_true(sc.subClassMethod(), 'subClassMethod() should work');
130+
131+
}, 'subclassing CountQueuingStrategy should work correctly');

0 commit comments

Comments
 (0)