MCPcopy Create free account
hub / github.com/cztomczak/cefpython / V8ContextHandler

Class V8ContextHandler

unittests/main_test.py:350–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348
349
350class V8ContextHandler(object):
351 def __init__(self, test_case):
352 self.test_case = test_case
353 self.OnContextCreatedFirstCall_True = False
354 self.OnContextCreatedSecondCall_True = False
355 self.OnContextReleased_True = False
356
357 def OnContextCreated(self, browser, frame):
358 """CEF creates one context when creating browser and this one is
359 released immediately. Then when it loads url another context is
360 created."""
361 if not self.OnContextCreatedFirstCall_True:
362 self.OnContextCreatedFirstCall_True = True
363 else:
364 self.test_case.assertFalse(self.OnContextCreatedSecondCall_True)
365 self.OnContextCreatedSecondCall_True = True
366 self.test_case.assertEqual(browser.GetIdentifier(), MAIN_BROWSER_ID)
367 self.test_case.assertEqual(frame.GetIdentifier(), 2)
368
369 def OnContextReleased(self, browser, frame):
370 """This gets called only for the initial empty context, see comment
371 in OnContextCreated. This should never get called for the main frame
372 of the main browser, because it happens during app exit and there
373 isn't enough time for the IPC messages to go through."""
374 self.test_case.assertFalse(self.OnContextReleased_True)
375 self.OnContextReleased_True = True
376 self.test_case.assertEqual(browser.GetIdentifier(), MAIN_BROWSER_ID)
377 self.test_case.assertEqual(frame.GetIdentifier(), 2)
378
379class External(object):
380 """Javascript 'window.external' object."""

Callers 1

test_mainMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_mainMethod · 0.68