Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Capture: Assert target is connected
Browse files Browse the repository at this point in the history
Closes gh-283
Ref gh-258
  • Loading branch information
bethge committed May 19, 2016
1 parent 04ae42f commit b8c0250
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ function assertActive(id) {
throw error;
}
}
function assertConnected(elem) {
if (!elem.ownerDocument.contains(elem)) {
var error = new Error('InvalidStateError');
error.name = 'InvalidStateError';
throw error;
}
}
function inActiveButtonState(id) {
var p = dispatcher.pointermap.get(id);
return p.buttons !== 0;
}
if (n.msPointerEnabled) {
s = function(pointerId) {
assertActive(pointerId);
assertConnected(this);
if (inActiveButtonState(pointerId)) {
this.msSetPointerCapture(pointerId);
}
Expand All @@ -27,6 +35,7 @@ if (n.msPointerEnabled) {
} else {
s = function setPointerCapture(pointerId) {
assertActive(pointerId);
assertConnected(this);
if (inActiveButtonState(pointerId)) {
dispatcher.setCapture(pointerId, this);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
define(function(require) {
var registerSuite = require('intern!object');
var w3cTest = require('../support/w3cTest');
var name = 'pointerevent_setpointercapture_disconnected-manual';

registerSuite({
name: name,

main: function() {
return w3cTest(this.remote, name + '.html')
.findById('target0')
.moveMouseTo(50, 25)
.clickMouseButton(0)
.end()
.checkResults();
}
});
});
2 changes: 1 addition & 1 deletion tests/intern.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ define({
// 'tests/functional/pointerevent_releasepointercapture_onpointercancel_touch-manual.js',
'tests/functional/pointerevent_releasepointercapture_onpointerup_mouse-manual',

// 'tests/functional/pointerevent_setpointercapture_disconnected-manual.js',
'tests/functional/pointerevent_setpointercapture_disconnected-manual.js',
'tests/functional/pointerevent_setpointercapture_inactive_button_mouse-manual.js',
'tests/functional/pointerevent_setpointercapture_invalid_pointerid-manual.js',
'tests/functional/pointerevent_setpointercapture_relatedtarget-manual.js'
Expand Down

0 comments on commit b8c0250

Please sign in to comment.