Auto merge of #14630 - bd339:iss14064, r=KiChjang

Use MediaQueryListEvent for media query list change events

<!-- Please describe your changes on the following line: -->

- Implements MediaQueryListEvent interface
- Makes MediaQueryList change events conform to the [spec](https://drafts.csswg.org/cssom-view/#evaluate-media-queries-and-report-changes)
- Updates matchMedia.html test to verify that the new event type is used

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14064

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14630)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-12-20 13:37:42 -08:00 committed by GitHub
commit bcf154d8e6
6 changed files with 120 additions and 2 deletions

View file

@ -126,12 +126,16 @@
window.onload = function(){
var rmListener = function(x){
assert_true(x instanceof MediaQueryListEvent, "Check that event is instance of MediaQueryListEvent.");
resizeTest.step(function(){
assert_unreached("removeListener was not successful.");
});
};
var dupListener = function(x){
assert_true(x instanceof MediaQueryListEvent, "Check that event is instance of MediaQueryListEvent.");
duplicateListenerTest.step(function(){
assert_false(mql1.dupListenerCalled, "Check that this listener has not been called before.");
mql1.dupListenerCalled = true;
@ -148,6 +152,8 @@
mql1.addListener(dupListener);
mql1.addListener(function(x){
assert_true(x instanceof MediaQueryListEvent, "Check that event is instance of MediaQueryListEvent.");
resizeTest.step(function(){
assert_equals(x, mql1, "Check that the MediaQueryList passed to the handler is the same that addListener was invoked on.");
assert_true(x.matches, "(max-height: 50px) should now pass.");
@ -162,6 +168,8 @@
});
mql1.addListener(function(x){
assert_true(x instanceof MediaQueryListEvent, "Check that event is instance of MediaQueryListEvent.");
listenerOrderTest.step(function(){
assert_true(mql1.firstListenerCalled, "Check that the listener added last is called last.");
});
@ -171,6 +179,8 @@
mql1.removeListener(rmListener);
mql2.addListener(function(x){
assert_true(x instanceof MediaQueryListEvent, "Check that event is instance of MediaQueryListEvent.");
duplicateListenerTest.done();
resizeTest.step(function(){
assert_equals(x, mql2, "Check that the MediaQueryList passed to the handler is the same that addListener was invoked on.");

View file

@ -143,6 +143,7 @@ test_interfaces([
"MediaError",
"MediaList",
"MediaQueryList",
"MediaQueryListEvent",
"MessageEvent",
"MimeType",
"MimeTypeArray",