MCPcopy
hub / github.com/scrapinghub/splash / init_storage

Method init_storage

splash/browser_tab.py:308–335  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

306 super(EventsStorage, self).__init__(parent)
307
308 def init_storage(self):
309 frame = self.parent().web_page.mainFrame()
310 eval_expr = u"eval({})".format(escape_js("""
311 (function() {{
312 var storage = window[{storage_name}];
313
314 storage.events = {{}};
315
316 storage.callMethod = function(methodName) {{
317 return function(eventId) {{
318 var eventsStorage = window[{storage_name}].events;
319 eventsStorage[eventId][methodName].call(eventsStorage[eventId]);
320 }};
321 }}
322
323 storage.preventDefault.connect(storage.callMethod('preventDefault'))
324 storage.stopImmediatePropagation.connect(storage.callMethod('stopImmediatePropagation'))
325 storage.stopPropagation.connect(storage.callMethod('stopPropagation'))
326
327 storage.add = function(event) {{
328 var id = storage.getId()
329 storage.events[id] = event;
330 return id;
331 }}
332 }})()
333 """.format(storage_name=escape_js(self.name))))
334
335 frame.evaluateJavaScript(eval_expr)
336
337 @pyqtSlot(name="getId", result=str)
338 def get_id(self):

Callers 1

_init_events_storageMethod · 0.80

Calls 1

escape_jsFunction · 0.90

Tested by

no test coverage detected