mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1264682 - [rep tests] Add tests for event rep. r=mikeratcliffe
This commit is contained in:
parent
dcae5b0335
commit
fc8f4ab2ec
@ -11,6 +11,7 @@ support-files =
|
||||
[test_reps_attribute.html]
|
||||
[test_reps_date-time.html]
|
||||
[test_reps_document.html]
|
||||
[test_reps_event.html]
|
||||
[test_reps_function.html]
|
||||
[test_reps_grip.html]
|
||||
[test_reps_grip-array.html]
|
||||
|
@ -0,0 +1,290 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test Event rep
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Rep test - Event</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script src="head.js" type="application/javascript;version=1.8"></script>
|
||||
<script type="application/javascript;version=1.8">
|
||||
window.onload = Task.async(function* () {
|
||||
let { Rep } = browserRequire("devtools/client/shared/components/reps/rep");
|
||||
let { Event } = browserRequire("devtools/client/shared/components/reps/event");
|
||||
|
||||
try {
|
||||
// Test that correct rep is chosen
|
||||
const renderedRep = shallowRenderComponent(Rep, { object: getGripStub("testEvent") });
|
||||
is(renderedRep.type, Event.rep, `Rep correctly selects ${Event.rep.displayName}`);
|
||||
|
||||
yield testEvent();
|
||||
yield testMouseEvent();
|
||||
yield testKeyboardEvent();
|
||||
yield testMessageEvent();
|
||||
} catch(e) {
|
||||
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
|
||||
} finally {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function testEvent() {
|
||||
const renderedComponent = renderComponent(Event.rep, { object: getGripStub("testEvent") });
|
||||
is(renderedComponent.textContent, "beforeprint", "Event rep has expected text content for an event");
|
||||
}
|
||||
|
||||
function testMouseEvent() {
|
||||
const renderedComponent = renderComponent(Event.rep, { object: getGripStub("testMouseEvent") });
|
||||
is(renderedComponent.textContent, "clickclientX=62, clientY=18", "Event rep has expected text content for a mouse event");
|
||||
}
|
||||
|
||||
function testKeyboardEvent() {
|
||||
const renderedComponent = renderComponent(Event.rep, { object: getGripStub("testKeyboardEvent") });
|
||||
is(renderedComponent.textContent, "keyupcharCode=0, keyCode=17", "Event rep has expected text content for a keyboard event");
|
||||
}
|
||||
|
||||
function testMessageEvent() {
|
||||
const renderedComponent = renderComponent(Event.rep, { object: getGripStub("testMessageEvent") });
|
||||
is(renderedComponent.textContent, "messageorigin=null, data=test data", "Event rep has expected text content for a message event");
|
||||
}
|
||||
|
||||
function getGripStub(name) {
|
||||
switch (name) {
|
||||
case "testEvent":
|
||||
return {
|
||||
"type": "object",
|
||||
"class": "Event",
|
||||
"actor": "server1.conn23.obj35",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 1,
|
||||
"preview": {
|
||||
"kind": "DOMEvent",
|
||||
"type": "beforeprint",
|
||||
"properties": {
|
||||
"isTrusted": true,
|
||||
"currentTarget": {
|
||||
"type": "object",
|
||||
"class": "Window",
|
||||
"actor": "server1.conn23.obj37",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 760,
|
||||
"preview": {
|
||||
"kind": "ObjectWithURL",
|
||||
"url": "http://example.com"
|
||||
}
|
||||
},
|
||||
"eventPhase": 2,
|
||||
"bubbles": false,
|
||||
"cancelable": false,
|
||||
"defaultPrevented": false,
|
||||
"timeStamp": 1466780008434005,
|
||||
"originalTarget": {
|
||||
"type": "object",
|
||||
"class": "Window",
|
||||
"actor": "server1.conn23.obj38",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 760,
|
||||
"preview": {
|
||||
"kind": "ObjectWithURL",
|
||||
"url": "http://example.com"
|
||||
}
|
||||
},
|
||||
"explicitOriginalTarget": {
|
||||
"type": "object",
|
||||
"class": "Window",
|
||||
"actor": "server1.conn23.obj39",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 760,
|
||||
"preview": {
|
||||
"kind": "ObjectWithURL",
|
||||
"url": "http://example.com"
|
||||
}
|
||||
},
|
||||
"NONE": 0
|
||||
},
|
||||
"target": {
|
||||
"type": "object",
|
||||
"class": "Window",
|
||||
"actor": "server1.conn23.obj36",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 760,
|
||||
"preview": {
|
||||
"kind": "ObjectWithURL",
|
||||
"url": "http://example.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
case "testMouseEvent":
|
||||
return {
|
||||
"type": "object",
|
||||
"class": "MouseEvent",
|
||||
"actor": "server1.conn20.obj39",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 1,
|
||||
"preview": {
|
||||
"kind": "DOMEvent",
|
||||
"type": "click",
|
||||
"properties": {
|
||||
"buttons": 0,
|
||||
"clientX": 62,
|
||||
"clientY": 18,
|
||||
"layerX": 0,
|
||||
"layerY": 0
|
||||
},
|
||||
"target": {
|
||||
"type": "object",
|
||||
"class": "HTMLDivElement",
|
||||
"actor": "server1.conn20.obj40",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 0,
|
||||
"preview": {
|
||||
"kind": "DOMNode",
|
||||
"nodeType": 1,
|
||||
"nodeName": "div",
|
||||
"attributes": {
|
||||
"id": "test"
|
||||
},
|
||||
"attributesLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
case "testKeyboardEvent":
|
||||
return {
|
||||
"type": "object",
|
||||
"class": "KeyboardEvent",
|
||||
"actor": "server1.conn21.obj49",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 1,
|
||||
"preview": {
|
||||
"kind": "DOMEvent",
|
||||
"type": "keyup",
|
||||
"properties": {
|
||||
"key": "Control",
|
||||
"charCode": 0,
|
||||
"keyCode": 17
|
||||
},
|
||||
"target": {
|
||||
"type": "object",
|
||||
"class": "HTMLBodyElement",
|
||||
"actor": "server1.conn21.obj50",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 0,
|
||||
"preview": {
|
||||
"kind": "DOMNode",
|
||||
"nodeType": 1,
|
||||
"nodeName": "body",
|
||||
"attributes": {},
|
||||
"attributesLength": 0
|
||||
}
|
||||
},
|
||||
"eventKind": "key",
|
||||
"modifiers": []
|
||||
}
|
||||
};
|
||||
|
||||
case "testMessageEvent":
|
||||
return {
|
||||
"type": "object",
|
||||
"class": "MessageEvent",
|
||||
"actor": "server1.conn3.obj34",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 1,
|
||||
"preview": {
|
||||
"kind": "DOMEvent",
|
||||
"type": "message",
|
||||
"properties": {
|
||||
"isTrusted": false,
|
||||
"data": "test data",
|
||||
"origin": "null",
|
||||
"lastEventId": "",
|
||||
"source": {
|
||||
"type": "object",
|
||||
"class": "Window",
|
||||
"actor": "server1.conn3.obj36",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 760,
|
||||
"preview": {
|
||||
"kind": "ObjectWithURL",
|
||||
"url": ""
|
||||
}
|
||||
},
|
||||
"ports": {
|
||||
"type": "object",
|
||||
"class": "MessagePortList",
|
||||
"actor": "server1.conn3.obj37",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 0
|
||||
},
|
||||
"currentTarget": {
|
||||
"type": "object",
|
||||
"class": "Window",
|
||||
"actor": "server1.conn3.obj38",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 760,
|
||||
"preview": {
|
||||
"kind": "ObjectWithURL",
|
||||
"url": ""
|
||||
}
|
||||
},
|
||||
"eventPhase": 2,
|
||||
"bubbles": false,
|
||||
"cancelable": false
|
||||
},
|
||||
"target": {
|
||||
"type": "object",
|
||||
"class": "Window",
|
||||
"actor": "server1.conn3.obj35",
|
||||
"extensible": true,
|
||||
"frozen": false,
|
||||
"sealed": false,
|
||||
"ownPropertyLength": 760,
|
||||
"preview": {
|
||||
"kind": "ObjectWithURL",
|
||||
"url": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user