@@ -28,17 +28,21 @@ cdef PyFrame GetPyFrame(CefRefPtr[CefFrame] cefFrame):
2828
2929 cdef PyFrame pyFrame
3030 cdef object frameId = cefFrame.get().GetIdentifier() # int64
31- if frameId < 0 :
32- # Underlying frame does not yet exist.
33- Debug(" GetPyFrame(): underlying frame does not yet exist"
34- " , frameId = {0}" .format(frameId))
35- return None
3631 cdef int browserId = cefFrame.get().GetBrowser().get().GetIdentifier()
3732 assert (frameId and browserId), " frameId or browserId empty"
3833 cdef object uniqueFrameId = GetUniqueFrameId(browserId, frameId)
3934
40- if uniqueFrameId in g_pyFrames:
41- return g_pyFrames[uniqueFrameId]
35+ if frameId < 0 :
36+ # Underlying frame does not yet exist. In such case PyFrame
37+ # is not stored in g_pyFrames since frameId is invalid.
38+ # However even though frame is not supposed to exist, you
39+ # can still call CefFrame.ExecuteFunction and it works fine
40+ # in tutorial.py example.
41+ Debug(" GetPyFrame(): underlying frame does not yet exist:"
42+ " browserId = {0}, frameId = {1}" .format(browserId, frameId))
43+ else :
44+ if uniqueFrameId in g_pyFrames:
45+ return g_pyFrames[uniqueFrameId]
4246
4347 # This code probably ain't needed.
4448 # ----
@@ -56,6 +60,7 @@ cdef PyFrame GetPyFrame(CefRefPtr[CefFrame] cefFrame):
5660 pyFrame.cefFrame = cefFrame
5761
5862 if uniqueFrameId in g_unreferenced_frames \
63+ or frameId < 0 \
5964 or browserId in g_unreferenced_browsers \
6065 or browserId in g_closed_browsers:
6166 # Browser was already globally unreferenced in OnBeforeClose,
0 commit comments