Commit f68571e3 authored by Robert Ma's avatar Robert Ma Committed by Commit Bot

Fix two testharness.js tests with harness errors due to stray asserts

All asserts need to be in a step func. Unfortunately this makes the
tests more verbose.

Found in https://github.com/web-platform-tests/wpt/pull/8748#issuecomment-398954260.

Change-Id: Ib15270d6093ea094b0f8c387cc4370f5154cf5dd
Reviewed-on: https://chromium-review.googlesource.com/1109689
Commit-Queue: Robert Ma <robertma@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569401}
parent 6ef585df
CONSOLE ERROR: line 2748: Uncaught Error: assert_false: Should not call createdCallback in UA ShadowRoot. expected false got true
CONSOLE ERROR: line 2748: Uncaught Error: assert_false: Should not call attachedCallback in UA ShadowRoot. expected false got true
CONSOLE ERROR: line 2748: Uncaught Error: assert_false: Should not call createdCallback in UA ShadowRoot. expected false got true
CONSOLE ERROR: line 2748: Uncaught Error: assert_false: Should not call attachedCallback in UA ShadowRoot. expected false got true
This is a testharness.js-based test. This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: assert_false: Should not call attachedCallback in UA ShadowRoot. expected false got true FAIL SVG <use> shadow trees should not be exposed through custom elements. assert_false: Should not call createdCallback in UA ShadowRoot. expected false got true
PASS SVG <use> shadow trees should not be exposed through custom elements.
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
<script> <script>
"use strict"; "use strict";
var t = async_test("SVG <use> shadow trees should not be exposed through custom elements.");
var instances = []; var instances = [];
function createPrototype(superClass) { function createPrototype(superClass) {
...@@ -34,40 +36,48 @@ function createPrototype(superClass) { ...@@ -34,40 +36,48 @@ function createPrototype(superClass) {
return scope; return scope;
} }
createdCallback() { createdCallback() {
t.step(() => {
this.instanceId = instances.length; this.instanceId = instances.length;
instances[this.instanceId] = this; instances[this.instanceId] = this;
assert_false(this.ownerScope instanceof ShadowRoot, assert_false(this.ownerScope instanceof ShadowRoot,
"Should not call createdCallback in UA ShadowRoot."); "Should not call createdCallback in UA ShadowRoot.");
});
} }
attachedCallback() { attachedCallback() {
t.step(() => {
assert_false(this.ownerScope instanceof ShadowRoot, assert_false(this.ownerScope instanceof ShadowRoot,
"Should not call attachedCallback in UA ShadowRoot."); "Should not call attachedCallback in UA ShadowRoot.");
assert_equals(instances[this.instanceId], this); assert_equals(instances[this.instanceId], this);
});
} }
detachedCallback() { detachedCallback() {
t.step(() => {
assert_false(this.ownerScope instanceof ShadowRoot, assert_false(this.ownerScope instanceof ShadowRoot,
"Should not call detachedCallback in UA ShadowRoot."); "Should not call detachedCallback in UA ShadowRoot.");
assert_equals(instances[this.instanceId], this); assert_equals(instances[this.instanceId], this);
});
} }
attributeChangedCallback() { attributeChangedCallback() {
t.step(() => {
assert_unreached("attributeChangedCallback should never be called."); assert_unreached("attributeChangedCallback should never be called.");
});
} }
}; };
return ElementType.prototype; return ElementType.prototype;
} }
// <rect is=x-rect> t.step(function () {
var XRectElement = document.registerElement('x-rect', { // <rect is=x-rect>
var XRectElement = document.registerElement('x-rect', {
extends: 'rect', extends: 'rect',
prototype: createPrototype(SVGRectElement), prototype: createPrototype(SVGRectElement),
}); });
// <x-test> // <x-test>
var XTestElement = document.registerElement('x-test', { var XTestElement = document.registerElement('x-test', {
prototype: createPrototype(HTMLElement), prototype: createPrototype(HTMLElement),
}); });
test(function () {
var template = document.getElementById("template"); var template = document.getElementById("template");
var svg = document.importNode(template.content, true).firstElementChild; var svg = document.importNode(template.content, true).firstElementChild;
var usedGroup = svg.getElementById("used-group"); var usedGroup = svg.getElementById("used-group");
...@@ -97,5 +107,9 @@ test(function () { ...@@ -97,5 +107,9 @@ test(function () {
assert_true(instances[i].ownerScope instanceof Document, assert_true(instances[i].ownerScope instanceof Document,
"No instances should be inside a ShadowRoot."); "No instances should be inside a ShadowRoot.");
} }
}, "SVG <use> shadow trees should not be exposed through custom elements.");
// Any callbacks will have been scheduled and run in microtasks,
// so end test after that.
t.step_timeout(t.step_func_done());
});
</script> </script>
CONSOLE WARNING: line 13: The AudioContext was not allowed to start. It must be resumed (or created) from a user gesture event handler. CONSOLE WARNING: line 13: The AudioContext was not allowed to start. It must be resumed (or created) from a user gesture event handler. https://goo.gl/7K7WLu
CONSOLE WARNING: line 23: The AudioContext was not allowed to start. It must be resumed (or created) from a user gesture event handler. CONSOLE WARNING: line 13: The Web Audio autoplay policy will be re-enabled in Chrome 70 (October 2018). Please check that your website is compatible with it. https://goo.gl/7K7WLu
CONSOLE WARNING: line 36: The AudioContext was not allowed to start. It must be resumed (or created) from a user gesture event handler. CONSOLE WARNING: line 23: The AudioContext was not allowed to start. It must be resumed (or created) from a user gesture event handler. https://goo.gl/7K7WLu
CONSOLE ERROR: line 2684: Uncaught Error: assert_equals: stateAfterClick expected "running" but got "suspended" CONSOLE WARNING: line 32: The AudioContext was not allowed to start. It must be resumed (or created) from a user gesture event handler. https://goo.gl/7K7WLu
CONSOLE WARNING: line 36: The AudioContext was not allowed to start. It must be resumed (or created) from a user gesture event handler. https://goo.gl/7K7WLu
CONSOLE WARNING: line 36: The Web Audio autoplay policy will be re-enabled in Chrome 70 (October 2018). Please check that your website is compatible with it. https://goo.gl/7K7WLu
This is a testharness.js-based test. This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: assert_equals: stateAfterClick expected "running" but got "suspended" FAIL Verify that autoplaying Web Audio from a cross origin iframe is blocked by mediaPlaybackRequiresUserGesture assert_equals: stateAfterClick expected "running" but got "suspended"
PASS Verify that autoplaying Web Audio from a cross origin iframe is blocked by mediaPlaybackRequiresUserGesture
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<body></body> <body></body>
<script> <script>
async_test(t => { async_test(t => {
window.addEventListener('message', e => { window.addEventListener('message', t.step_func(e => {
switch (e.data.msg) { switch (e.data.msg) {
case 'clickme': case 'clickme':
if (!('eventSender' in window)) if (!('eventSender' in window))
...@@ -37,7 +37,7 @@ async_test(t => { ...@@ -37,7 +37,7 @@ async_test(t => {
default: default:
assert_unreached(); assert_unreached();
} }
}); }));
var f = document.createElement('iframe'); var f = document.createElement('iframe');
f.src = 'http://localhost:8000/webaudio/resources/autoplay-crossorigin-iframe.html'; f.src = 'http://localhost:8000/webaudio/resources/autoplay-crossorigin-iframe.html';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment