Пример #1
0
def test_focus_element(stubs):
    """Test getting focus element with a fake frame/element.

    Testing this with a real webpage is almost impossible because the window
    and the element would have focus, which is hard to achieve consistently in
    a test.
    """
    frame = stubs.FakeWebFrame(QRect(0, 0, 100, 100))
    elem = get_webelem()
    frame.focus_elem = elem._elem
    assert webelem.focus_elem(frame)._elem is elem._elem
Пример #2
0
def test_focus_element(stubs):
    """Test getting focus element with a fake frame/element.

    Testing this with a real webpage is almost impossible because the window
    and the element would have focus, which is hard to achieve consistently in
    a test.
    """
    frame = stubs.FakeWebFrame(QRect(0, 0, 100, 100))
    elem = get_webelem()
    frame.focus_elem = elem._elem
    assert webelem.focus_elem(frame)._elem is elem._elem
Пример #3
0
 def mouserelease_insertmode(self):
     """If we have an insertmode check scheduled, handle it."""
     if not self._check_insertmode:
         return
     self._check_insertmode = False
     try:
         elem = webelem.focus_elem(self.page().currentFrame())
     except (webelem.IsNullError, RuntimeError):
         log.mouse.debug("Element/page vanished!")
         return
     if elem.is_editable():
         log.mouse.debug("Clicked editable element (delayed)!")
         modeman.enter(self.win_id, usertypes.KeyMode.insert,
                       'click-delayed', only_if_normal=True)
     else:
         log.mouse.debug("Clicked non-editable element (delayed)!")
         if config.get('input', 'auto-leave-insert-mode'):
             modeman.maybe_leave(self.win_id, usertypes.KeyMode.insert,
                                 'click-delayed')
Пример #4
0
 def mouserelease_insertmode(self):
     """If we have an insertmode check scheduled, handle it."""
     if not self._check_insertmode:
         return
     self._check_insertmode = False
     try:
         elem = webelem.focus_elem(self.page().currentFrame())
     except (webelem.IsNullError, RuntimeError):
         log.mouse.debug("Element/page vanished!")
         return
     if elem.is_editable():
         log.mouse.debug("Clicked editable element (delayed)!")
         modeman.enter(self.win_id, usertypes.KeyMode.insert,
                       'click-delayed', only_if_normal=True)
     else:
         log.mouse.debug("Clicked non-editable element (delayed)!")
         if config.get('input', 'auto-leave-insert-mode'):
             modeman.maybe_leave(self.win_id, usertypes.KeyMode.insert,
                                 'click-delayed')