Update web-platform-tests to revision acd60f9e55532f03fc905e61591b7fd7db2f08d1

This commit is contained in:
Ms2ger 2015-08-26 09:41:40 +02:00
parent a1cd27e6a3
commit be4f0ad8de
44 changed files with 544 additions and 663 deletions

View file

@ -7,39 +7,185 @@
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var expected = [
"parse-inline",
"parse-ext",
"dom-inline",
"dom-ext",
];
var tests = {};
expected.forEach(function(id) {
tests[id] = async_test("Script " + id);
var data = {
"parse-inline" : [],
"parse-ext" : [],
"dom-inline" : [],
"dom-ext" : [],
"nested" : ["nested-outer","nested-inner","nested-outer"],
"script-exec" : ["script-exec-before-after","script-exec-before-after"],
"script-load-error" : [null],
"script-window-error" : ["script-error-compile","script-error-runtime"],
"timeout" : [null],
"eval" : [],
"xhr-test" : [],
"script-svg" : [],
"script-async" : [],
"script-defer" : []
};
var expected = {};
var actual = {};
Object.keys(data).forEach(function(id) {
var test_expected = data[id];
if(test_expected.length == 0) {
test_expected = [id];
}
expected[id] = test_expected;
actual[id] = [];
});
function verifyScript(id) {
var tests = {};
setup({allow_uncaught_exception : true});
Object.keys(expected).forEach(function(id) {
var testmsg = "Script " + id;
tests[id] = async_test(testmsg);
});
function verify(id) {
tests[id].step(function() {
assert_equals(document.currentScript, document.getElementById(id));
this.done();
});
actual[id].push(document.currentScript);
})
}
function finish(id) {
tests[id].step(function() {
assert_array_equals(actual[id],expected[id].map(function(id) {
return document.getElementById(id);
}));
this.done();
})
}
</script>
<!-- Test parser inserted scripts -->
<script id="parse-inline">
verifyScript("parse-inline");
verify('parse-inline');
finish('parse-inline')
</script>
<script id="parse-ext" src="data:text/plain,verifyScript('parse-ext');"></script>
<script id="parse-ext" src="data:text/plain,verify('parse-ext')"></script>
<script>finish('parse-ext');</script>
<!-- Test DOM inserted scripts -->
<script>
var s = document.createElement("script");
s.textContent = "verifyScript('dom-inline');";
s.textContent = "verify('dom-inline');";
s.id = "dom-inline";
document.body.appendChild(s);
finish('dom-inline');
s = document.createElement("script");
s.src = "data:text/plain,verifyScript('dom-ext');";
s.src = "data:text/plain,verify('dom-ext');";
s.id = "dom-ext";
s.onload = function() {
finish('dom-ext');
}
document.body.appendChild(s);
</script>
<!-- Test Nested scripts -->
<script id="nested-outer">
verify("nested");
var s = document.createElement("script");
s.textContent = "verify('nested')";
s.id = "nested-inner";
document.body.appendChild(s);
verify("nested");
finish('nested');
</script>
<!-- Test beforescriptexecute and afterscriptexecute -->
<script id="script-exec-before-after">
function verifyScriptExec(e) {
verify('script-exec');
}
document.addEventListener('beforescriptexecute', verifyScriptExec, false);
document.addEventListener('afterscriptexecute', verifyScriptExec, false);
var s = document.createElement("script");
s.id = "script-exec-test";
s.textContent = "function nop() { return false }";
document.body.appendChild(s);
document.removeEventListener('beforescriptexecute', verifyScriptExec);
document.removeEventListener('afterscriptexecute', verifyScriptExec);
finish('script-exec');
</script>
<!-- Test script load error event listener -->
<script>
function testLoadFail() {
verify('script-load-error');
finish('script-load-error');
}
</script>
<script src="http://some.nonexistant.test/fail" id="script-load-error" onerror="testLoadFail()">
</script>
<!-- Test for runtime and compile time errors -->
<script>
window.onerror = function() {
verify('script-window-error');
}
var s = document.createElement("script");
s.id = "script-error-compile";
s.textContent = "{";
document.body.appendChild(s);
window.onerror = function() {
verify('script-window-error');
}
s = document.createElement("script");
s.id = "script-error-runtime";
s.textContent = "undefinedfn();";
document.body.appendChild(s);
finish('script-window-error');
</script>
<!-- Verify in setTimeout -->
<script>
setTimeout(function() {
verify('timeout');
finish('timeout');
},0);
</script>
<!-- Verify in eval -->
<script id="eval">
eval('verify("eval")');
finish("eval");
</script>
<!-- Verify in synchronous xhr -->
<script id="xhr-test">
var request = new XMLHttpRequest();
request.open('GET','/',false);
request.send(null);
if(request.status === 200) {
verify('xhr-test');
finish('xhr-test');
}
</script>
<!-- Testing script within svg -->
<svg>
<script id="script-svg">
verify('script-svg');
finish('script-svg');
</script>
</svg>
<!-- Test script async and defer -->
<script id='script-async' async src='data:text/plain,verify("script-async"),finish("script-async")'></script>
<script id='script-defer' defer src='data:text/plain,verify("script-defer"),finish("script-defer")'></script>

View file

@ -0,0 +1,18 @@
<!doctype html>
<meta charset=utf-8>
<title>HTMLElement#click</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function() {
var element = document.createElement("div");
var received = false;
element.addEventListener("click", this.step_func(function(e) {
received = true;
assert_false(e.isTrusted, "Event should not be trusted")
}));
element.click();
assert_true(received, "click event should have been dispatched synchronously");
})
</script>

View file

@ -25,6 +25,10 @@
var base = document.createElement("base");
base.setAttribute("href", "/foo/bar");
document.head.appendChild(base);
t1.add_cleanup(function () {
document.head.removeChild(base);
});
assert_resolve_url(document, location.href.replace(location.pathname, "/foo"));
assert_equals(document.baseURI, base.href, "The document base URL should be URL of the first base element that has an href attribute.");
});
@ -55,10 +59,10 @@
var iframe = document.createElement("iframe");
iframe.onload = this.step_func_done(function () {
var doc = iframe.contentDocument;
var base = doc.body.appendChild(document.createElement("base"));
var base = doc.body.appendChild(doc.createElement("base"));
base.href = "sub/";
assert_resolve_url(doc, location.href.replace("/document-base-url.html", "/sub"));
assert_equals(doc.baseURI, document.baseURI);
assert_equals(doc.baseURI, document.baseURI.replace("/document-base-url.html", "/sub/"));
});
iframe.setAttribute("src", "about:blank");
document.body.appendChild(iframe);

View file

@ -0,0 +1,27 @@
<!doctype html>
<html>
<head>
<title>requestAnimationFrame callback exception reported to error handler</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://w3c.github.io/web-performance/specs/RequestAnimationFrame/Overview.html#dom-windowanimationtiming-requestanimationframe"/>
</head>
<body>
<div id="log"></div>
<script>
var custom_exception = 'requestAnimationFrameException';
setup({allow_uncaught_exception : true});
async_test(function (t) {
addEventListener("error",function(e) {
t.step(function() {
assert_equals(e.error.message, custom_exception);
t.done();
})
});
window.requestAnimationFrame(function () {
throw new Error(custom_exception);
});
}, "requestAnimationFrame callback exceptions are reported to error handler");
</script>
</body>
</html>

View file

@ -0,0 +1,22 @@
<!doctype html>
<html>
<head>
<title>requestAnimationFrame must be triggered once</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://w3c.github.io/web-performance/specs/RequestAnimationFrame/Overview.html#dom-windowanimationtiming-requestanimationframe"/>
</head>
<body>
<div id="log"></div>
<script>
async_test(function (t) {
t.step(function() {
assert_false(document.hidden, "document.hidden must be exist and be false to run this test properly");
});
window.requestAnimationFrame(function () {
t.step(function() { assert_true(true); t.done(); });
});
}, "requestAnimationFrame callback is invoked at least once before the timeout");
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!doctype html>
<html>
<head>
<title>cancelAnimationFrame does nothing</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://w3c.github.io/web-performance/specs/RequestAnimationFrame/Overview.html#dom-windowanimationtiming-cancelanimationframe"/>
</head>
<body>
<div id="log"></div>
<script>
test(function (t) {
window.cancelAnimationFrame(42);
assert_true(true);
}, "cancelAnimationFrame does nothing if there is no callback with the given handle");
</script>
</body>
</html>

View file

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>idlharness test</title>
<link rel="author" title="Kensaku Komatsu" href="mailto:kensaku.komatsu@gmail.com" />
<link rel="help" href="http://www.w3.org/TR/animation-timing/#definitions"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>idlharness test</h1>
<p>This test validates the WebIDL included in the Timing control for script-based animations specification.</p>
<pre id='untested_idl' style='display:none'>
[PrimaryGlobal]
interface Window {
};
</pre>
<pre id='idl'>
partial interface Window {
long requestAnimationFrame(FrameRequestCallback callback);
void cancelAnimationFrame(long handle);
};
callback FrameRequestCallback = void (DOMHighResTimeStamp time);
</pre>
<script>
(function() {
var idl_array = new IdlArray();
idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
idl_array.add_idls(document.getElementById("idl").textContent);
idl_array.add_objects({Window: ["window"]});
idl_array.test();
})();
</script>
<div id="log"></div>
</body>
</html>

View file

@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<title>requestAnimationFrame in queue get the same timestamp</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="http://w3c.github.io/animation-timing/#dfn-invoke-callbacks-algorithm"/>
</head>
<body>
<div id="log"></div>
<script>
test(function (t) {
var a = 0, b = 0;
/* REASONING:
* These two methods that will be called with a timestamp. Because
* they execute right after eachother, they're added to the same
* queue and SHOULD be timestamped with the same value.
*/
window.requestAnimationFrame(function() { a = arguments[0]; });
window.requestAnimationFrame(function() { b = arguments[0]; });
setTimeout(function() {
assert_true(a != 0);
assert_true(b != 0);
assert_true(a == b);
}, 100);
}, "requestAnimationFrame will timestamp events in the same queue with the same time");
</script>
</body>
</html>