|
41 | 41 | print("Chrome: <b>"+version.chrome_version+"</b>"); |
42 | 42 | print("CEF: <b>"+version.cef_version+"</b>"); |
43 | 43 |
|
| 44 | + // Test binding function: test_function |
| 45 | + test_function(); |
| 46 | + print("test_function() ok"); |
| 47 | +
|
44 | 48 | // Test binding property: test_property1 |
45 | 49 | if (test_property1 == "Test binding property to the 'window' object") { |
46 | 50 | print("test_property_1 ok"); |
|
56 | 60 | throw new Error("test_property2 contains invalid value"); |
57 | 61 | } |
58 | 62 |
|
59 | | - // Test binding function: test_function |
60 | | - test_function(); |
61 | | - print("test_function() ok"); |
| 63 | + // Test binding function: test_property3_function |
| 64 | + test_property3_function(); |
| 65 | + print("test_property3_function() ok"); |
62 | 66 |
|
63 | 67 | // Test binding external object and use of javascript<>python callbacks |
64 | 68 | var start_time = new Date().getTime(); |
@@ -145,6 +149,11 @@ def test_main(self): |
145 | 149 | bindings.SetFunction("test_function", external.test_function) |
146 | 150 | bindings.SetProperty("test_property1", external.test_property1) |
147 | 151 | bindings.SetProperty("test_property2", external.test_property2) |
| 152 | + # Property with a function value can also be bound. CEF Python |
| 153 | + # supports passing functions as callbacks when called from |
| 154 | + # javascript, and as a side effect any value and in this case |
| 155 | + # a property can also be a function. |
| 156 | + bindings.SetProperty("test_property3_function", external.test_property3_function) |
148 | 157 | bindings.SetProperty("cefpython_version", cef.GetVersion()) |
149 | 158 | bindings.SetObject("external", external) |
150 | 159 | browser.SetJavascriptBindings(bindings) |
@@ -310,13 +319,18 @@ def __init__(self, test_case): |
310 | 319 | # Asserts for True/False will be checked just before shutdown |
311 | 320 | self.test_for_True = True # Test whether asserts are working correctly |
312 | 321 | self.test_function_True = False |
| 322 | + self.test_property3_function_True = False |
313 | 323 | self.test_callbacks_True = False |
314 | 324 | self.py_callback_True = False |
315 | 325 |
|
316 | 326 | def test_function(self): |
317 | 327 | """Test binding function to the 'window' object.""" |
318 | 328 | self.test_function_True = True |
319 | 329 |
|
| 330 | + def test_property3_function(self): |
| 331 | + """Test binding function to the 'window' object.""" |
| 332 | + self.test_property3_function_True = True |
| 333 | + |
320 | 334 | def test_callbacks(self, js_callback): |
321 | 335 | """Test both javascript and python callbacks.""" |
322 | 336 | def py_callback(msg_from_js): |
|
0 commit comments