Update web-platform-tests to revision 95aad3bd9b82b5c65d84d53517b65ba084de9394

This commit is contained in:
Ms2ger 2016-02-11 17:10:01 +01:00
parent 5942e9e3cb
commit e8ed816728
145 changed files with 2024 additions and 578 deletions

View file

@ -1,5 +1,6 @@
@Ms2ger
@gsnedders
@jdm
@jgraham
@plehegar
@sideshowbarker

View file

@ -0,0 +1,8 @@
<!DOCTYPE html>
<style>
body {
height: 2000px;
width: 2000px;
}
</style>
<body> Blank 1 </body>

View file

@ -0,0 +1,8 @@
<!DOCTYPE html>
<style>
body {
height: 2000px;
width: 2000px;
}
</style>
<body> Blank 2 </body>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<style>
body {
height: 2000px;
width: 2000px;
}
#fragment {
position: absolute;
top: 800px;
background-color: #faa;
display: block;
height: 100px;
width: 100px;
}
</style>
<body>
Page with fragment
<a id="fragment" name="fragment" class='box'></a>
</body>

View file

@ -0,0 +1,34 @@
<!doctype html>
<title>Verify existence and basic read/write function of history.scrollRestoration</title>
<style>
body {
height: 2000px;
width: 2000px;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript">
'use strict';
test(function() {
assert_equals(history.scrollRestoration, 'auto');
}, 'Default value is "auto"');
test(function() {
history.scrollRestoration = 'manual';
assert_equals(history.scrollRestoration, 'manual', 'should be able to set "manual"');
history.scrollRestoration = 'auto';
assert_equals(history.scrollRestoration, 'auto', 'should be able to set "auto"');
}, 'It is writable');
test(function() {
history.scrollRestoration = 'auto';
for (var v of [3.1415, {}, 'bogus']) {
history.scrollRestoration = v;
assert_equals(history.scrollRestoration, 'auto', `setting to invalid value (${v}) should be ignored`);
}
}, 'Invalid values are ignored');
</script>

View file

@ -0,0 +1,67 @@
<!DOCTYPE html>
<meta name=timeout content=long>
<title>Precedence of scroll restoration mode over fragment scrolling in cross-origin history traversal</title>
<style>
iframe {
height: 300px;
width: 300px;
}
</style>
<body>
<iframe></iframe>
</body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript">
'use strict';
// The test does the following navigation steps for iframe
// 1. load page-with-fragment.html#fragment
// 2. load blank1
// 3. go back to page-with-fragment.html
async_test(function(t) {
var iframe = document.querySelector('iframe');
var baseURL = location.href.substring(0, location.href.lastIndexOf('/'));
var steps = [
function() {
iframe.src = 'resources/page-with-fragment.html#fragment';
}, function() {
assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/page-with-fragment.html#fragment', 'should be on page-with-fragment page');
// wait one animation frame to ensure layout is run and fragment scrolling is complete
iframe.contentWindow.requestAnimationFrame(function() {
assert_equals(iframe.contentWindow.scrollY, 800, 'should scroll to fragment');
iframe.contentWindow.history.scrollRestoration = 'manual';
assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual');
setTimeout(next, 0);
});
}, function() {
// navigate to a new page from a different origin
iframe.src = iframe.src.replace("http://", "http://www.").replace("page-with-fragment.html#fragment", "blank1.html");
}, function() {
// going back causes the iframe to traverse back
history.back();
}, function() {
// coming back from history, scrollRestoration should be set to manual and respected
assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/page-with-fragment.html#fragment', 'should be back on page-with-fragment page');
iframe.contentWindow.requestAnimationFrame(function() {
assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual', 'navigating back should retain scrollRestoration value');
assert_equals(iframe.contentWindow.scrollX, 0, 'should not scroll to fragment');
assert_equals(iframe.contentWindow.scrollY, 0, 'should not scroll to fragment');
t.done();
});
}
];
var stepCount = 0;
var next = t.step_func(function() {
steps[stepCount++]();
});
iframe.onload = next;
next();
}, 'Manual scroll restoration should take precedent over scrolling to fragment in cross origin navigation');
</script>

View file

@ -0,0 +1,54 @@
<!DOCTYPE html>
<style>
body {
height: 2000px;
width: 2000px;
}
#fragment {
position: absolute;
top: 800px;
background-color: #faa;
display: block;
height: 100px;
width: 100px;
}
</style>
<body>
<a id="fragment" name="fragment" class='box'></a>
</body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript">
'use strict';
async_test(function(t) {
history.scrollRestoration = 'manual';
assert_equals(history.scrollRestoration, 'manual');
location.hash = '#fragment';
assert_equals(window.scrollY, 800, 'new navigations should scroll to fragment');
// create a new entry and reset the scroll before verification
history.pushState(null, null, '#done');
window.scrollTo(0, 0);
assert_equals(window.scrollY, 0, 'should reset scroll before verification');
setTimeout(function() {
// setup verification
window.addEventListener('hashchange', t.step_func(function() {
assert_equals(location.hash, '#fragment');
assert_equals(history.scrollRestoration, 'manual');
// navigating back should give precedent to history restoration which is 'manual'
assert_equals(window.scrollX, 0, 'should not scroll to fragment');
assert_equals(window.scrollY, 0, 'should not scroll to fragment');
t.done();
}));
// kick off verification
window.history.back();
}, 0);
}, 'Manual scroll restoration should take precedent over scrolling to fragment in cross doc navigation');
</script>

View file

@ -0,0 +1,71 @@
<!DOCTYPE html>
<meta name=timeout content=long>
<title>Correct behaviour of scroll restoration mode is cross origin history traversal</title>
<style>
iframe {
height: 300px;
width: 300px;
}
</style>
<body>
<iframe></iframe>
</body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript">
'use strict';
// The test does the following navigation steps for iframe
// 1. load blank1
// 2. load blank2
// 3. go back to blank1
async_test(function(t) {
var iframe = document.querySelector('iframe');
var baseURL = location.href.substring(0, location.href.lastIndexOf('/'));
var steps = [
function() {
iframe.src = 'resources/blank1.html';
},
function() {
assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/blank1.html', 'should be on first blank page');
iframe.contentWindow.history.scrollRestoration = 'manual';
assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual');
iframe.contentWindow.scrollTo(500, 500);
assert_equals(iframe.contentWindow.scrollX, 500, 'scripted scrolling should take effect');
assert_equals(iframe.contentWindow.scrollY, 500, 'scripted scrolling should take effect');
setTimeout(next, 0);
},
function() {
// navigate to new page
iframe.src = 'resources/blank2.html';
},
function() {
assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/blank2.html', 'should be on second blank page');
assert_equals(iframe.contentWindow.history.scrollRestoration, 'auto', 'new page loads should set scrollRestoration to "auto"');
setTimeout(next, 0);
}, function() {
iframe.contentWindow.history.back();
}, function() {
// coming back scrollRestoration should be restored to 'manual' and respected
assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/blank1.html', 'should be back on first blank page');
assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual', 'navigating back should retain scrollRestoration value');
assert_equals(iframe.contentWindow.scrollX, 0, 'horizontal scroll offset should not be restored');
assert_equals(iframe.contentWindow.scrollY, 0, 'vertical scroll offset should not be restored');
t.done();
}
];
var stepCount = 0;
var next = t.step_func(function() {
steps[stepCount++]();
});
iframe.onload = next;
next();
}, 'Navigating to new page should reset to "auto" and navigating back should restore and respect scroll restoration mode');
</script>

View file

@ -0,0 +1,81 @@
<!DOCTYPE html>
<title>Correct behaviour of scroll restoration mode in same document history traversals</title>
<style>
body {
height: 10000px;
width: 10000px;
}
</style>
<body></body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript">
'use strict';
async_test(function(t) {
history.scrollRestoration = 'auto';
window.scrollTo(0, 0);
// create history entries and then verify the impact of scrollRestoration
// when they are popped
var entries = {
/* For scroll restoration mode 'auto', the spec does not require scroll
position to be restored at any particular value. */
'#1': {type: 'push', expectedScroll: null, scrollRestoration: 'auto'},
'#2': {type: 'replace', expectedScroll: null, scrollRestoration: 'auto'},
/* For scroll restoration mode 'manual', the spec requires scroll position
not to be restored. So we expect [555,555] which is the latest position
before navigation. */
'#3': {type: 'push', expectedScroll: [555, 555], scrollRestoration: 'manual'},
'#4': {type: 'replace', expectedScroll: [555, 555], scrollRestoration: 'manual'}
};
// setup entries
for (var key in entries) {
var entry = entries[key],
beforeValue = history.scrollRestoration,
newValue = entry.scrollRestoration;
var args = [{key: key}, '', key];
if (entry.type == 'push') {
history.pushState.apply(history, args);
} else {
history.pushState(null, '', key);
history.replaceState.apply(history, args);
}
assert_equals(history.scrollRestoration, beforeValue, `history.scrollRestoration value is retained after pushing new state`);
history.scrollRestoration = newValue;
assert_equals(history.scrollRestoration, newValue, `Setting scrollRestoration to ${newValue} works as expected`);
window.scrollBy(50, 100);
}
// setup verification
window.addEventListener('hashchange', t.step_func(function() {
var key = location.hash,
entry = entries[key];
if (key === '') {
t.done();
return;
}
assert_equals(history.state.key, key, `state should have key: ${key}`);
assert_equals(history.scrollRestoration, entry.scrollRestoration, 'scrollRestoration is updated correctly');
if (entry.expectedScroll) {
assert_equals(window.scrollX, entry.expectedScroll[0], `scrollX is correct for ${key}`);
assert_equals(window.scrollY, entry.expectedScroll[1], `scrollY is correct for ${key}`);
}
window.history.back();
}));
// reset the scroll and kick off the verification
setTimeout(function() {
history.pushState(null, null, '#done');
window.scrollTo(555, 555);
window.history.back();
}, 0);
}, 'history.{push,replace}State retain scroll restoration mode and navigation in the same document respects it');
</script>

View file

@ -285,7 +285,7 @@ interface Element : Node {
attribute DOMString id;
attribute DOMString className;
[SameObject] readonly attribute DOMTokenList classList;
[SameObject, PutForwards=value] readonly attribute DOMTokenList classList;
boolean hasAttributes();
[SameObject] readonly attribute NamedNodeMap attributes;
@ -462,14 +462,12 @@ interface DOMTokenList {
void add(DOMString... tokens);
void remove(DOMString... tokens);
boolean toggle(DOMString token, optional boolean force);
void replace(DOMString token, DOMString newToken);
boolean supports(DOMString token);
attribute DOMString value;
stringifier;
// iterable<DOMString>;
};
interface DOMSettableTokenList : DOMTokenList {
attribute DOMString value;
};
</script>
};</script>
<!-- UI Events IDLs -->
<script type=text/plain class=untested>
[Constructor(DOMString type, optional UIEventInit eventInitDict)]
@ -998,10 +996,10 @@ interface HTMLElement : Element {
// microdata
attribute boolean itemScope;
[PutForwards=value] readonly attribute DOMSettableTokenList itemType;
[PutForwards=value] readonly attribute DOMTokenList itemType;
attribute DOMString itemId;
[PutForwards=value] readonly attribute DOMSettableTokenList itemRef;
[PutForwards=value] readonly attribute DOMSettableTokenList itemProp;
[PutForwards=value] readonly attribute DOMTokenList itemRef;
[PutForwards=value] readonly attribute DOMTokenList itemProp;
readonly attribute HTMLPropertiesCollection properties;
attribute any itemValue; // acts as DOMString on setting
@ -1014,7 +1012,7 @@ interface HTMLElement : Element {
attribute DOMString accessKey;
readonly attribute DOMString accessKeyLabel;
attribute boolean draggable;
[PutForwards=value] readonly attribute DOMSettableTokenList dropzone;
[PutForwards=value] readonly attribute DOMTokenList dropzone;
attribute DOMString contentEditable;
readonly attribute boolean isContentEditable;
attribute HTMLMenuElement? contextMenu;
@ -1052,11 +1050,11 @@ interface HTMLLinkElement : HTMLElement {
attribute DOMString href;
attribute DOMString crossOrigin;
attribute DOMString rel;
readonly attribute DOMTokenList relList;
[PutForwards=value] readonly attribute DOMTokenList relList;
attribute DOMString media;
attribute DOMString hreflang;
attribute DOMString type;
[PutForwards=value] readonly attribute DOMSettableTokenList sizes;
[PutForwards=value] readonly attribute DOMTokenList sizes;
// also has obsolete members
};
@ -1132,9 +1130,9 @@ interface HTMLDivElement : HTMLElement {
interface HTMLAnchorElement : HTMLElement {
attribute DOMString target;
attribute DOMString download;
[PutForwards=value] readonly attribute DOMSettableTokenList ping;
[PutForwards=value] readonly attribute DOMTokenList ping;
attribute DOMString rel;
readonly attribute DOMTokenList relList;
[PutForwards=value] readonly attribute DOMTokenList relList;
attribute DOMString hreflang;
attribute DOMString type;
@ -1192,7 +1190,7 @@ interface HTMLIFrameElement : HTMLElement {
attribute DOMString src;
attribute DOMString srcdoc;
attribute DOMString name;
[PutForwards=value] readonly attribute DOMSettableTokenList sandbox;
[PutForwards=value] readonly attribute DOMTokenList sandbox;
attribute boolean seamless;
attribute boolean allowFullscreen;
attribute DOMString width;
@ -1502,9 +1500,9 @@ interface HTMLAreaElement : HTMLElement {
attribute DOMString shape;
attribute DOMString target;
attribute DOMString download;
[PutForwards=value] readonly attribute DOMSettableTokenList ping;
[PutForwards=value] readonly attribute DOMTokenList ping;
attribute DOMString rel;
readonly attribute DOMTokenList relList;
[PutForwards=value] readonly attribute DOMTokenList relList;
// hreflang and type are not reflected
};
HTMLAreaElement implements HTMLHyperlinkElementUtils;
@ -1572,7 +1570,7 @@ interface HTMLTableHeaderCellElement : HTMLTableCellElement {
interface HTMLTableCellElement : HTMLElement {
attribute unsigned long colSpan;
attribute unsigned long rowSpan;
[PutForwards=value] readonly attribute DOMSettableTokenList headers;
[PutForwards=value] readonly attribute DOMTokenList headers;
readonly attribute long cellIndex;
// also has obsolete members
@ -1816,7 +1814,7 @@ interface HTMLKeygenElement : HTMLElement {
};
interface HTMLOutputElement : HTMLElement {
[PutForwards=value] readonly attribute DOMSettableTokenList htmlFor;
[PutForwards=value] readonly attribute DOMTokenList htmlFor;
readonly attribute HTMLFormElement? form;
attribute DOMString name;
@ -2309,8 +2307,11 @@ interface BarProp {
attribute boolean visible;
};
enum ScrollRestoration { "auto", "manual" };
interface History {
readonly attribute long length;
attribute ScrollRestoration scrollRestoration;
readonly attribute any state;
void go(optional long delta);
void back();

View file

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Focus events fire at correct targets in correct order in simple case</title>
<link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
<link rel="help" href="https://html.spec.whatwg.org/#focus-update-steps">
<link rel="help" href="https://html.spec.whatwg.org/#focus-chain">
<meta name="flags" content="dom">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<input type="text" id="a">
<script>
// Record all the focus event targets in an array.
// Modulo special cases in the "focus update steps" algorithm,
// this should be the same as the new focus chain, except in reverse order.
var newFocusChainReversedNotQuite = [];
var pushTarget = function (e) {
newFocusChainReversedNotQuite.push(e.target);
};
// Window is the root node for event dispatch per https://html.spec.whatwg.org/multipage/webappapis.html#events-and-the-window-object
window.addEventListener('focus', pushTarget, true);// Use event capturing since focus event doesn't bubble
var input = document.getElementById('a');
input.focus();
window.removeEventListener('focus', pushTarget, true);
test(function() {
assert_array_equals(newFocusChainReversedNotQuite, [input], "Exactly 1 focus event should fire and its target should be the input");
}, "Focus events fire at correct targets in correct order in simple case");
</script>
</body>
</html>

View file

@ -19,7 +19,7 @@
<li class="upper-roman">fifth item</li>
<li class="disc">sixth item</li>
<li class="circle">seventh item</li>
<li class="square">eigth item</li>
<li class="square">eighth item</li>
<li class="none">ninth item</li>
<ol>
<li class="decimal">first ordered item</li>
@ -29,7 +29,7 @@
<li class="upper-roman">fifth ordered item</li>
<li class="disc">sixth ordered item</li>
<li class="circle">seventh ordered item</li>
<li class="square">eigth ordered item</li>
<li class="square">eighth ordered item</li>
<li class="none">ninth ordered item</li>
</ol>
<ul>
@ -40,6 +40,6 @@
<li class="upper-roman">fifth unordered item</li>
<li class="disc">sixth unordered item</li>
<li class="circle">seventh unordered item</li>
<li class="square">eigth unordered item</li>
<li class="square">eighth unordered item</li>
<li class="none">ninth unordered item</li>
</ul>

View file

@ -9,7 +9,7 @@
<li type=I>fifth item</li>
<li type=disc>sixth item</li>
<li type=circle>seventh item</li>
<li type=square>eigth item</li>
<li type=square>eighth item</li>
<li type=none>ninth item</li>
<ol>
<li type=1>first ordered item</li>
@ -19,7 +19,7 @@
<li type=I>fifth ordered item</li>
<li type=disc>sixth ordered item</li>
<li type=circle>seventh ordered item</li>
<li type=square>eigth ordered item</li>
<li type=square>eighth ordered item</li>
<li type=none>ninth ordered item</li>
</ol>
<ul>
@ -30,6 +30,6 @@
<li type=I>fifth unordered item</li>
<li type=disc>sixth unordered item</li>
<li type=circle>seventh unordered item</li>
<li type=square>eigth unordered item</li>
<li type=square>eighth unordered item</li>
<li type=none>ninth unordered item</li>
</ul>

View file

@ -12,7 +12,7 @@
<li type="I">fifth item</li>
<li type="disc">sixth item</li>
<li type="circle">seventh item</li>
<li type="square">eigth item</li>
<li type="square">eighth item</li>
<li type="none">ninth item</li>
<ol>
<li type="1">first ordered item</li>
@ -22,7 +22,7 @@
<li type="I">fifth ordered item</li>
<li type="disc">sixth ordered item</li>
<li type="circle">seventh ordered item</li>
<li type="square">eigth ordered item</li>
<li type="square">eighth ordered item</li>
<li type="none">ninth ordered item</li>
</ol>
<ul>
@ -33,7 +33,7 @@
<li type="I">fifth unordered item</li>
<li type="disc">sixth unordered item</li>
<li type="circle">seventh unordered item</li>
<li type="square">eigth unordered item</li>
<li type="square">eighth unordered item</li>
<li type="none">ninth unordered item</li>
</ul>
</body>

View file

@ -0,0 +1,45 @@
<!DOCTYPE HTML>
<html>
<head>
<title>HTML5 Media Elements: 'media' attribute</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<link rel="author" title="Microsoft" href="http://www.microsoft.com/" />
<link rel="help" href="http://www.w3.org/TR/html5/video.html#the-source-element" />
<meta name="assert" content="'media' attribute is 'all' by default." />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="/common/media.js"></script>
<script type="text/javascript">
var videotest = async_test();
function do_play(event)
{
videotest.step(function() {
var vid = document.getElementById("video0");
assert_true(vid.currentSrc.indexOf("movie_300") > 0);
});
videotest.done();
}
</script>
</head>
<body>
<div id='log'></div>
<video id="video0" autoplay onplay="do_play(event);">
<script type="text/javascript">
document.write(
"<source media='not all' src='" + getVideoURI("/media/movie_300") + "'" +
" />"
);
document.write(
"<source src='" + getVideoURI("/media/movie_5") + "'" +
" media='all' />"
);
</script>
Your browser does not support media elements.
</video>
</body>
</html>

View file

@ -22,7 +22,6 @@ t('loopCount'); // added in r692, replaced with playCount in r1105.
t('currentLoop'); // added in r692, removed in r2401.
t('addCuePoint'); // added in r721, replaced with addCueRange in r1106.
t('removeCuePoint'); // added in r721, replaced with removeCueRanges in r1106.
t('media', 'source'); // added in r724, removed in r8472.
t('playCount'); // added in r1105, removed in r2401.
t('addCueRange'); // added in r1106, removed in r5070.
t('removeCueRanges'); // added in r1106, removed in r5070.

View file

@ -3,13 +3,15 @@
<title>HTML Test: The embed element represents a document</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="stylesheet" href="/resources/testharness.css">
<meta name="assert" content="Check if the embed element represents a document when a text/html resource source is used">
<body>
<script type="application/javascript">
var childLoaded = false;
t = async_test("Test document type embedding");
addEventListener("load", t.step_func_done(function() { assert_true(childLoaded); }));
window.childLoaded = false;
async_test(function() {
addEventListener("load", this.step_func_done(function() {
assert_true(window.childLoaded);
}));
}, "Test document type embedding");
</script>
<embed src="embed-iframe.html">
</body>

View file

@ -23,25 +23,25 @@ var btn = document.getElementById("btn"),
document.forms.fm1.onsubmit = t1.step_func(function (evt) {
evt.preventDefault();
assert_true(evt.isTrusted, "The isTrusted attribute of the submit event shoud be true.");
assert_true(evt.bubbles, "The bubbles attribute of the submit event shoud be true.");
assert_true(evt.cancelable, "The cancelable attribute of the submit event shoud be true.");
assert_true(evt.isTrusted, "The isTrusted attribute of the submit event should be true.");
assert_true(evt.bubbles, "The bubbles attribute of the submit event should be true.");
assert_true(evt.cancelable, "The cancelable attribute of the submit event should be true.");
assert_true(evt instanceof Event, "The submit event is an instance of Event interface.");
t1.done();
});
document.forms.fm1.onreset = t2.step_func(function (evt) {
assert_true(evt.isTrusted, "The isTrusted attribute of the reset event shoud be true.");
assert_true(evt.bubbles, "The bubbles attribute of the reset event shoud be true.");
assert_true(evt.cancelable, "The cancelable attribute of the reset event shoud be true.");
assert_true(evt.isTrusted, "The isTrusted attribute of the reset event should be true.");
assert_true(evt.bubbles, "The bubbles attribute of the reset event should be true.");
assert_true(evt.cancelable, "The cancelable attribute of the reset event should be true.");
assert_true(evt instanceof Event, "The reset event is an instance of Event interface.");
t2.done();
});
document.getElementById("menu").onshow = t3.step_func(function (evt) {
assert_true(evt.isTrusted, "The isTrusted attribute of the show event shoud be true.");
assert_true(evt.isTrusted, "The isTrusted attribute of the show event should be true.");
assert_equals(evt.relatedTarget, menu_btn, "The relatedTarget attribute should be initialized to the related button element.");
assert_true(evt.cancelable, "The cancelable attribute of the show event shoud be true.");
assert_true(evt.cancelable, "The cancelable attribute of the show event should be true.");
assert_true(evt instanceof RelatedEvent, "The show event is an instance of RelatedEvent interface.");
t3.done();
});

View file

@ -2,7 +2,8 @@
<meta charset=utf-8>
<title>input type checkbox</title>
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/#checkbox-state-(type=checkbox)">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#checkbox-state-(type=checkbox)">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#run-synthetic-click-activation-steps">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
@ -19,28 +20,39 @@
checkbox4 = document.getElementById('checkbox4'),
checkbox5 = document.getElementById('checkbox5'),
checkbox6 = document.getElementById('checkbox6'),
c1_input_fired = false, c1_change_fired = false,
t1 = async_test("click on mutable checkbox fires the input and change events"),
c1_click_fired = false,
c1_input_fired = false,
c1_change_fired = false,
t1 = async_test("click on mutable checkbox fires a click event, then an input event, then a change event"),
t2 = async_test("click on non-mutable checkbox doesn't fire the input or change event"),
t3 = async_test("pre-activation steps on unchecked checkbox"),
t4 = async_test("pre-activation steps on checked checkbox"),
t5 = async_test("canceled activation steps on unchecked checkbox"),
t6 = async_test("canceled activation steps on unchecked checkbox (indeterminate=true in onclick)");
checkbox1.oninput= t1.step_func(function(e) {
checkbox1.onclick = t1.step_func(function () {
c1_click_fired = true;
assert_false(c1_input_fired, "click event should fire before input event");
assert_false(c1_change_fired, "click event should fire before change event");
});
checkbox1.oninput = t1.step_func(function(e) {
c1_input_fired = true;
assert_true(c1_click_fired, "input event should fire after click event");
assert_false(c1_change_fired, "input event should fire before change event");
assert_true(e.bubbles, "event should bubble");
assert_true(e.isTrusted, "event should be trusted");
assert_false(e.cancelable, "event shoud not be cancelable");
assert_false(e.isTrusted, "click()-initiated event should be trusted");
assert_false(e.cancelable, "event should not be cancelable");
assert_true(checkbox1.checked, "checkbox is checked");
assert_false(checkbox1.indeterminate, "checkbox is not indeterminate");
});
checkbox1.onchange = t1.step_func(function(e) {
c1_change_fired = true;
assert_true(c1_click_fired, "change event should fire after click event");
assert_true(c1_input_fired, "change event should fire after input event");
assert_true(e.bubbles, "event should bubble")
assert_true(e.isTrusted, "event should be trusted");
assert_false(e.cancelable, "event shoud not be cancelable");
assert_false(e.isTrusted, "click()-initiated event should be trusted");
assert_false(e.cancelable, "event should not be cancelable");
assert_true(checkbox1.checked, "checkbox is checked");
assert_false(checkbox1.indeterminate, "checkbox is not indeterminate");
});

View file

@ -18,12 +18,12 @@
document.getElementById('file').oninput = t1.step_func_done(function(e) {
assert_true(e.bubbles, "input event bubbles");
assert_true(e.isTrusted, "input event should be trusted");
assert_false(e.cancelable, "input event shoud not be cancelable");
assert_false(e.cancelable, "input event should not be cancelable");
})
document.getElementById('file').onchange = t2.step_func_done(function(e) {
assert_true(e.bubbles, "change event bubbles");
assert_true(e.isTrusted, "change event should be trusted");
assert_false(e.cancelable, "change event shoud not be cancelable");
assert_false(e.cancelable, "change event should not be cancelable");
assert_true(input.files instanceof FileList);
assert_equals(input.value, "C:\\fakepath\\" + input.files[0].name);
})

View file

@ -15,8 +15,8 @@
<input type=radio id=radio5>
<input type=radio id=radio6 disabled>
<input type=radio id=radio71 checked>
<input type=radio id=radio72>
<input type=radio name="group5" id=radio71 checked>
<input type=radio name="group5" id=radio72>
<input type=radio name=group3 id=radio8 checked>
<input type=radio name=group3 id=radio9>
@ -37,8 +37,7 @@
radio9 = document.getElementById('radio9'),
radio10 = document.getElementById('radio10'),
radio11 = document.getElementById('radio11'),
t1 = async_test("click on mutable radio fires the input event"),
t2 = async_test("click on mutable radio fires the change event"),
t1 = async_test("click on mutable radio fires click event, then input event, then change event"),
t3 = async_test("click on non-mutable radio doesn't fire the input event"),
t4 = async_test("click on non-mutable radio doesn't fire the change event"),
t5 = async_test("canceled activation steps on unchecked radio"),
@ -80,18 +79,28 @@
assert_false(radio11.checked);
}, "changing the name of a radio input element and setting its checkedness to true makes all the other elements' checkedness in the same radio button group be set to false");
radio5.oninput= t1.step_func(function(e) {
input_fired = true;
assert_true(e.bubbles, "event should bubble")
assert_true(e.isTrusted, "event should be trusted");
assert_false(e.cancelable, "event shoud not be cancelable");
radio5.onclick = t1.step_func(function(e) {
click_fired = true;
assert_false(input_fired, "click event should fire before input event");
assert_false(change_fired, "click event should fire before change event");
});
radio5.onchange = t2.step_func(function(e) {
radio5.oninput = t1.step_func(function(e) {
input_fired = true;
assert_true(click_fired, "input event should fire after click event");
assert_false(change_fired, "input event should fire before change event");
assert_true(e.bubbles, "input event should bubble")
assert_false(e.isTrusted, "click()-initiated input event shouldn't be trusted");
assert_false(e.cancelable, "input event should not be cancelable");
});
radio5.onchange = t1.step_func(function(e) {
change_fired = true;
assert_true(e.bubbles, "event should bubble")
assert_true(e.isTrusted, "event should be trusted");
assert_false(e.cancelable, "event shoud not be cancelable");
assert_true(click_fired, "change event should fire after click event");
assert_true(input_fired, "change event should fire after input event");
assert_true(e.bubbles, "change event should bubble")
assert_false(e.isTrusted, "click()-initiated change event shouldn't be trusted");
assert_false(e.cancelable, "change event should not be cancelable");
});
radio6.oninput= t3.step_func_done(function(e) {
@ -108,11 +117,6 @@
t1.done();
});
t2.step(function() {
assert_true(change_fired);
t2.done();
})
t3.step(function(){
radio6.click();
t3.done();
@ -120,18 +124,20 @@
});
radio72.onclick = t5.step_func_done(function(e){
assert_false(radio71.checked);
assert_true(radio72.checked);
assert_false(radio71.checked, "click on radio should uncheck other radio in same group");
assert_true(radio72.checked, "click on radio should check that radio");
e.preventDefault();
assert_false(radio71.checked);
assert_true(radio72.checked);
// The cancelation of the click doesn't have an effect until after all the click event handlers have been run.
assert_false(radio71.checked, "radio remains unchecked immediately after click event on other radio in same group is canceled");
assert_true(radio72.checked, "clicked radio remains checked immediately after click event is canceled");
});
t5.step(function(){
assert_true(radio71.checked);
assert_false(radio72.checked);
assert_true(radio71.checked, "initially checked radio should be checked");
assert_false(radio72.checked, "other radios in same group as initially-checked radio should be unchecked");
radio72.click();
assert_true(radio71.checked);
assert_false(radio72.checked);
// Now that the click event has been fully dispatched, its cancelation has taken effect.
assert_true(radio71.checked, "canceled click event on radio should leave the previously-checked radio checked");
assert_false(radio72.checked, "canceled click event on previously-unchecked radio should leave that radio unchecked");
});
</script>