-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event path attribute test for Shadow DOM. #194
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Shadow DOM Test: TODO</title> | ||
<link rel="author" title="Masakazu Hattori" href="mailto:mshattori@gmail.com"> | ||
<!-- You must have at least one spec link, but may have as many as are covered in the test. --> | ||
<!-- Be sure to make the main testing area first in the order --> | ||
<link rel="help" href="https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#partial-event-attributes"> | ||
<meta name="assert" content="Event path attribute test for Shadow DOM"> | ||
<meta name="flags" content="dom"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<div id="log"></div> | ||
<section id="shadow-host" style='display:none'> | ||
<button id="a-child">test it</button> | ||
</section> | ||
<script> | ||
var t = async_test("Event path attribute test for Shadow DOM"); | ||
|
||
var host = document.getElementById('shadow-host'); | ||
var child = document.getElementById('a-child'); | ||
|
||
var root = host.webkitCreateShadowRoot(); | ||
var shadowDiv = document.createElement('div'); | ||
shadowDiv.id = "shadow-div"; | ||
shadowDiv.innerHTML = '<content></content>'; | ||
root.appendChild(shadowDiv); | ||
|
||
var verifyCount = 0; | ||
host.addEventListener('click', | ||
verifier( | ||
[toName(child), toName(host)], // expected | ||
[toName(shadowDiv)] // unexpected | ||
), | ||
false); | ||
shadowDiv.addEventListener('click', | ||
verifier( | ||
[toName(child), toName(host), toName(shadowDiv)], // expected | ||
[] // unexpected | ||
), | ||
false); | ||
child.addEventListener('click', | ||
verifier( | ||
[toName(child), toName(host)], // expected | ||
[toName(shadowDiv)] // unexpected | ||
), | ||
false); | ||
child.click(); | ||
|
||
function verifier(expected, unexpected) { | ||
verifyCount += 1; | ||
return function (evt) { | ||
var self = this; | ||
t.step(function() { | ||
var path = evt.path; | ||
for (var i = 0; i < path.length; i++) { | ||
var thisName = toName(self); | ||
var p = path[i]; | ||
var pName = toName(p); | ||
if (expected.indexOf(pName) >= 0) { | ||
var msg = pName + ' is expected in path of ' + thisName; | ||
assert_true(true, msg); | ||
} | ||
if (unexpected.indexOf(pName) >= 0) { | ||
var msg = pName + ' is unexpected in path of ' + thisName; | ||
assert_unreached(msg); | ||
} | ||
} | ||
verifyCount -= 1; | ||
if (verifyCount <= 0) { | ||
t.done(); | ||
} | ||
}); | ||
}; | ||
} | ||
function toName(e) { | ||
return e.localName + '#' + e.id; | ||
} | ||
</script> | ||
</body> | ||
</html> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a good test.
Suppose that even.path is empty. The test doesn't fail. :)
You should make sure that each expected node is surely included in the event.path.