OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 "use strict"; | |
6 | |
7 installClass("Internals", function(global) { | |
8 var InternalsPrototype = Object.create(Element.prototype); | |
9 | |
10 InternalsPrototype.constructor = function() { | |
11 this.m_shortAttribute = -1; | |
12 this.m_stringAttribute = "xxx"; | |
13 this.m_nodeAttribute = null; | |
14 } | |
15 | |
16 InternalsPrototype.doNothing = function() { | |
17 } | |
18 | |
19 InternalsPrototype.return123 = function() { | |
20 return 123; | |
21 } | |
22 | |
23 InternalsPrototype.echoInteger = function(value) { | |
24 return value; | |
25 } | |
26 | |
27 InternalsPrototype.echoString = function(value) { | |
28 return value; | |
29 } | |
30 | |
31 InternalsPrototype.echoNode = function(value) { | |
32 return value; | |
33 } | |
34 | |
35 InternalsPrototype.addInteger = function(value1, value2) { | |
36 return value1 + value2; | |
37 } | |
38 | |
39 InternalsPrototype.addString = function(value1, value2) { | |
40 return value1 + value2; | |
41 } | |
42 | |
43 InternalsPrototype.setIntegerToDocument = function(document, value) { | |
44 document.integer = value; | |
45 } | |
46 | |
47 InternalsPrototype.getIntegerFromDocument = function(document) { | |
48 return document.integer; | |
49 } | |
50 | |
51 InternalsPrototype.setIntegerToPrototype = function(value) { | |
52 this.integer = value; | |
53 } | |
54 | |
55 InternalsPrototype.getIntegerFromPrototype = function() { | |
56 return this.integer; | |
57 } | |
58 | |
59 InternalsPrototype.createElement = function(document) { | |
60 return document.createElement("div"); | |
61 } | |
62 | |
63 InternalsPrototype.appendChild = function(node1, node2) { | |
64 node1.appendChild(node2); | |
65 } | |
66 | |
67 InternalsPrototype.firstChild = function(node) { | |
68 return node.firstChild; | |
69 } | |
70 | |
71 InternalsPrototype.nextSibling = function(node) { | |
72 return node.nextSibling; | |
73 } | |
74 | |
75 InternalsPrototype.innerHTML = function(node) { | |
76 return node.innerHTML; | |
77 } | |
78 | |
79 InternalsPrototype.setInnerHTML = function(node, string) { | |
80 node.innerHTML = string; | |
81 } | |
82 | |
83 InternalsPrototype.addClickListener = function(node) { | |
84 node.addEventListener("click", function () { | |
85 node.innerHTML = "clicked"; | |
86 }); | |
87 } | |
88 | |
89 InternalsPrototype.clickNode = function(document, node) { | |
90 var event = new MouseEvent("click", { bubbles: true, cancelable: true, v
iew: global }); | |
91 node.dispatchEvent(event); | |
92 } | |
93 | |
94 Object.defineProperty(InternalsPrototype, "readonlyShortAttribute", { | |
95 get: function() { return 123; } | |
96 }); | |
97 | |
98 Object.defineProperty(InternalsPrototype, "shortAttribute", { | |
99 get: function() { return this.m_shortAttribute; }, | |
100 set: function(value) { this.m_shortAttribute = value; } | |
101 }); | |
102 | |
103 Object.defineProperty(InternalsPrototype, "stringAttribute", { | |
104 get: function() { return this.m_stringAttribute; }, | |
105 set: function(value) { this.m_stringAttribute = value; } | |
106 }); | |
107 | |
108 Object.defineProperty(InternalsPrototype, "nodeAttribute", { | |
109 get: function() { return this.m_nodeAttribute; }, | |
110 set: function(value) { this.m_nodeAttribute = value; } | |
111 }); | |
112 | |
113 return InternalsPrototype; | |
114 }); | |
OLD | NEW |