| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 "use strict"; | 5 "use strict"; |
| 6 | 6 |
| 7 installClass("PrivateScriptTest", function(global, InternalsPrototype) { | 7 installClass("PrivateScriptTest", function(global, PrivateScriptTestPrototype) { |
| 8 | 8 |
| 9 InternalsPrototype.initialize = function() { | 9 PrivateScriptTestPrototype.initialize = function() { |
| 10 this.m_shortAttribute = -1; | 10 this.m_shortAttribute = -1; |
| 11 this.m_stringAttribute = "xxx"; | 11 this.m_stringAttribute = "xxx"; |
| 12 this.m_nodeAttribute = null; | 12 this.m_nodeAttribute = null; |
| 13 this.m_stringAttributeForPrivateScriptOnly = "yyy"; | 13 this.m_stringAttributeForPrivateScriptOnly = "yyy"; |
| 14 } | 14 } |
| 15 | 15 |
| 16 InternalsPrototype.doNothing = function() { | 16 PrivateScriptTestPrototype.doNothing = function() { |
| 17 } | 17 } |
| 18 | 18 |
| 19 InternalsPrototype.return123 = function() { | 19 PrivateScriptTestPrototype.return123 = function() { |
| 20 return 123; | 20 return 123; |
| 21 } | 21 } |
| 22 | 22 |
| 23 InternalsPrototype.echoInteger = function(value) { | 23 PrivateScriptTestPrototype.echoInteger = function(value) { |
| 24 return value; | 24 return value; |
| 25 } | 25 } |
| 26 | 26 |
| 27 InternalsPrototype.echoString = function(value) { | 27 PrivateScriptTestPrototype.echoString = function(value) { |
| 28 return value; | 28 return value; |
| 29 } | 29 } |
| 30 | 30 |
| 31 InternalsPrototype.echoNode = function(value) { | 31 PrivateScriptTestPrototype.echoNode = function(value) { |
| 32 return value; | 32 return value; |
| 33 } | 33 } |
| 34 | 34 |
| 35 InternalsPrototype.addValues_ = function(value1, value2) { | 35 PrivateScriptTestPrototype.addValues_ = function(value1, value2) { |
| 36 return value1 + value2; | 36 return value1 + value2; |
| 37 } | 37 } |
| 38 | 38 |
| 39 InternalsPrototype.addInteger = function(value1, value2) { | 39 PrivateScriptTestPrototype.addInteger = function(value1, value2) { |
| 40 return this.addValues_(value1, value2); | 40 return this.addValues_(value1, value2); |
| 41 } | 41 } |
| 42 | 42 |
| 43 InternalsPrototype.addString = function(value1, value2) { | 43 PrivateScriptTestPrototype.addString = function(value1, value2) { |
| 44 return this.addValues_(value1, value2); | 44 return this.addValues_(value1, value2); |
| 45 } | 45 } |
| 46 | 46 |
| 47 InternalsPrototype.setIntegerToDocument = function(document, value) { | 47 PrivateScriptTestPrototype.setIntegerToDocument = function(document, value)
{ |
| 48 document.integer = value; | 48 document.integer = value; |
| 49 } | 49 } |
| 50 | 50 |
| 51 InternalsPrototype.getIntegerFromDocument = function(document) { | 51 PrivateScriptTestPrototype.getIntegerFromDocument = function(document) { |
| 52 return document.integer; | 52 return document.integer; |
| 53 } | 53 } |
| 54 | 54 |
| 55 InternalsPrototype.setIntegerToPrototype = function(value) { | 55 PrivateScriptTestPrototype.setIntegerToPrototype = function(value) { |
| 56 this.integer = value; | 56 this.integer = value; |
| 57 } | 57 } |
| 58 | 58 |
| 59 InternalsPrototype.getIntegerFromPrototype = function() { | 59 PrivateScriptTestPrototype.getIntegerFromPrototype = function() { |
| 60 return this.integer; | 60 return this.integer; |
| 61 } | 61 } |
| 62 | 62 |
| 63 InternalsPrototype.createElement = function(document) { | 63 PrivateScriptTestPrototype.createElement = function(document) { |
| 64 return document.createElement("div"); | 64 return document.createElement("div"); |
| 65 } | 65 } |
| 66 | 66 |
| 67 InternalsPrototype.appendChild = function(node1, node2) { | 67 PrivateScriptTestPrototype.appendChild = function(node1, node2) { |
| 68 node1.appendChild(node2); | 68 node1.appendChild(node2); |
| 69 } | 69 } |
| 70 | 70 |
| 71 InternalsPrototype.firstChild = function(node) { | 71 PrivateScriptTestPrototype.firstChild = function(node) { |
| 72 return node.firstChild; | 72 return node.firstChild; |
| 73 } | 73 } |
| 74 | 74 |
| 75 InternalsPrototype.nextSibling = function(node) { | 75 PrivateScriptTestPrototype.nextSibling = function(node) { |
| 76 return node.nextSibling; | 76 return node.nextSibling; |
| 77 } | 77 } |
| 78 | 78 |
| 79 InternalsPrototype.innerHTML = function(node) { | 79 PrivateScriptTestPrototype.innerHTML = function(node) { |
| 80 return node.innerHTML; | 80 return node.innerHTML; |
| 81 } | 81 } |
| 82 | 82 |
| 83 InternalsPrototype.setInnerHTML = function(node, string) { | 83 PrivateScriptTestPrototype.setInnerHTML = function(node, string) { |
| 84 node.innerHTML = string; | 84 node.innerHTML = string; |
| 85 } | 85 } |
| 86 | 86 |
| 87 InternalsPrototype.addClickListener = function(node) { | 87 PrivateScriptTestPrototype.addClickListener = function(node) { |
| 88 node.addEventListener("click", function () { | 88 node.addEventListener("click", function () { |
| 89 node.innerHTML = "clicked"; | 89 node.innerHTML = "clicked"; |
| 90 }); | 90 }); |
| 91 } | 91 } |
| 92 | 92 |
| 93 InternalsPrototype.clickNode = function(document, node) { | 93 PrivateScriptTestPrototype.clickNode = function(document, node) { |
| 94 var event = new MouseEvent("click", { bubbles: true, cancelable: true, v
iew: global }); | 94 var event = new MouseEvent("click", { bubbles: true, cancelable: true, v
iew: global }); |
| 95 node.dispatchEvent(event); | 95 node.dispatchEvent(event); |
| 96 } | 96 } |
| 97 | 97 |
| 98 Object.defineProperty(InternalsPrototype, "readonlyShortAttribute", { | 98 Object.defineProperty(PrivateScriptTestPrototype, "readonlyShortAttribute",
{ |
| 99 get: function() { return 123; } | 99 get: function() { return 123; } |
| 100 }); | 100 }); |
| 101 | 101 |
| 102 Object.defineProperty(InternalsPrototype, "shortAttribute", { | 102 Object.defineProperty(PrivateScriptTestPrototype, "shortAttribute", { |
| 103 get: function() { return this.m_shortAttribute; }, | 103 get: function() { return this.m_shortAttribute; }, |
| 104 set: function(value) { this.m_shortAttribute = value; } | 104 set: function(value) { this.m_shortAttribute = value; } |
| 105 }); | 105 }); |
| 106 | 106 |
| 107 Object.defineProperty(InternalsPrototype, "stringAttribute", { | 107 Object.defineProperty(PrivateScriptTestPrototype, "stringAttribute", { |
| 108 get: function() { return this.m_stringAttribute; }, | 108 get: function() { return this.m_stringAttribute; }, |
| 109 set: function(value) { this.m_stringAttribute = value; } | 109 set: function(value) { this.m_stringAttribute = value; } |
| 110 }); | 110 }); |
| 111 | 111 |
| 112 Object.defineProperty(InternalsPrototype, "nodeAttribute", { | 112 Object.defineProperty(PrivateScriptTestPrototype, "nodeAttribute", { |
| 113 get: function() { return this.m_nodeAttribute; }, | 113 get: function() { return this.m_nodeAttribute; }, |
| 114 set: function(value) { this.m_nodeAttribute = value; } | 114 set: function(value) { this.m_nodeAttribute = value; } |
| 115 }); | 115 }); |
| 116 | 116 |
| 117 Object.defineProperty(InternalsPrototype, "nodeAttributeThrowsIndexSizeError
", { | 117 Object.defineProperty(PrivateScriptTestPrototype, "nodeAttributeThrowsIndexS
izeError", { |
| 118 get: function() { throw new DOMExceptionInPrivateScript("IndexSizeError"
, "getter threw error"); }, | 118 get: function() { throw new DOMExceptionInPrivateScript("IndexSizeError"
, "getter threw error"); }, |
| 119 set: function(value) { throw new DOMExceptionInPrivateScript("IndexSizeE
rror", "setter threw error"); } | 119 set: function(value) { throw new DOMExceptionInPrivateScript("IndexSizeE
rror", "setter threw error"); } |
| 120 }); | 120 }); |
| 121 | 121 |
| 122 InternalsPrototype.voidMethodThrowsDOMSyntaxError = function() { | 122 PrivateScriptTestPrototype.voidMethodThrowsDOMSyntaxError = function() { |
| 123 throw new DOMExceptionInPrivateScript("SyntaxError", "method threw error
"); | 123 throw new DOMExceptionInPrivateScript("SyntaxError", "method threw error
"); |
| 124 } | 124 } |
| 125 | 125 |
| 126 InternalsPrototype.voidMethodThrowsError = function() { | 126 PrivateScriptTestPrototype.voidMethodThrowsError = function() { |
| 127 throw new Error("method threw Error"); | 127 throw new Error("method threw Error"); |
| 128 } | 128 } |
| 129 | 129 |
| 130 InternalsPrototype.voidMethodThrowsTypeError = function() { | 130 PrivateScriptTestPrototype.voidMethodThrowsTypeError = function() { |
| 131 throw new TypeError("method threw TypeError"); | 131 throw new TypeError("method threw TypeError"); |
| 132 } | 132 } |
| 133 | 133 |
| 134 InternalsPrototype.voidMethodThrowsRangeError = function() { | 134 PrivateScriptTestPrototype.voidMethodThrowsRangeError = function() { |
| 135 throw new RangeError("method threw RangeError"); | 135 throw new RangeError("method threw RangeError"); |
| 136 } | 136 } |
| 137 | 137 |
| 138 InternalsPrototype.voidMethodThrowsSyntaxError = function() { | 138 PrivateScriptTestPrototype.voidMethodThrowsSyntaxError = function() { |
| 139 throw new SyntaxError("method threw SyntaxError"); | 139 throw new SyntaxError("method threw SyntaxError"); |
| 140 } | 140 } |
| 141 | 141 |
| 142 InternalsPrototype.voidMethodThrowsReferenceError = function() { | 142 PrivateScriptTestPrototype.voidMethodThrowsReferenceError = function() { |
| 143 throw new ReferenceError("method threw ReferenceError"); | 143 throw new ReferenceError("method threw ReferenceError"); |
| 144 } | 144 } |
| 145 | 145 |
| 146 InternalsPrototype.voidMethodWithStackOverflow = function() { | 146 PrivateScriptTestPrototype.voidMethodWithStackOverflow = function() { |
| 147 function f() { f(); } | 147 function f() { f(); } |
| 148 f(); | 148 f(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 InternalsPrototype.addIntegerForPrivateScriptOnly = function(value1, value2)
{ | 151 PrivateScriptTestPrototype.addIntegerForPrivateScriptOnly = function(value1,
value2) { |
| 152 return value1 + value2; | 152 return value1 + value2; |
| 153 } | 153 } |
| 154 | 154 |
| 155 Object.defineProperty(InternalsPrototype, "stringAttributeForPrivateScriptOn
ly", { | 155 Object.defineProperty(PrivateScriptTestPrototype, "stringAttributeForPrivate
ScriptOnly", { |
| 156 get: function() { return this.m_stringAttributeForPrivateScriptOnly; }, | 156 get: function() { return this.m_stringAttributeForPrivateScriptOnly; }, |
| 157 set: function(value) { this.m_stringAttributeForPrivateScriptOnly = valu
e; } | 157 set: function(value) { this.m_stringAttributeForPrivateScriptOnly = valu
e; } |
| 158 }); | 158 }); |
| 159 | 159 |
| 160 InternalsPrototype.addIntegerImplementedInCPP = function(value1, value2) { | 160 PrivateScriptTestPrototype.addIntegerImplementedInCPP = function(value1, val
ue2) { |
| 161 return this.addIntegerImplementedInCPPForPrivateScriptOnly(value1, value
2); | 161 return this.addIntegerImplementedInCPPForPrivateScriptOnly(value1, value
2); |
| 162 } | 162 } |
| 163 | 163 |
| 164 Object.defineProperty(InternalsPrototype, "stringAttributeImplementedInCPP",
{ | 164 Object.defineProperty(PrivateScriptTestPrototype, "stringAttributeImplemente
dInCPP", { |
| 165 get: function() { return this.m_stringAttributeImplementedInCPPForPrivat
eScriptOnly; }, | 165 get: function() { return this.m_stringAttributeImplementedInCPPForPrivat
eScriptOnly; }, |
| 166 set: function(value) { this.m_stringAttributeImplementedInCPPForPrivateS
criptOnly = value; } | 166 set: function(value) { this.m_stringAttributeImplementedInCPPForPrivateS
criptOnly = value; } |
| 167 }); | 167 }); |
| 168 }); | 168 }); |
| OLD | NEW |