def _filter_signals(self, signal, tab, *args): """Filter signals and trigger TabbedBrowser signals if needed. Triggers signal if the original signal was sent from the _current_ tab and not from any other one. The original signal does not matter, since we get the new signal and all args. Args: signal: The signal to emit if the sender was the current widget. tab: The WebView which the filter belongs to. *args: The args to pass to the signal. """ log_signal = debug.signal_name(signal) not in self.BLACKLIST tabbed_browser = objreg.get('tabbed-browser', scope='window', window=self._win_id) try: tabidx = tabbed_browser.indexOf(tab) except RuntimeError: # The tab has been deleted already return if tabidx == tabbed_browser.currentIndex(): if log_signal: log.signals.debug("emitting: {} (tab {})".format( debug.dbg_signal(signal, args), tabidx)) signal.emit(*args) else: if log_signal: log.signals.debug("ignoring: {} (tab {})".format( debug.dbg_signal(signal, args), tabidx))
def test_dbg_signal(stubs, args, expected): assert debug.dbg_signal(stubs.FakeSignal(), args) == expected
def test_dbg_signal_newline(self): """Test dbg_signal() with a newline.""" self.assertEqual(debug.dbg_signal(self.signal, ['foo\nbar']), r"fake('foo\nbar')")
def test_dbg_signal_eliding(self): """Test eliding in dbg_signal().""" self.assertEqual(debug.dbg_signal(self.signal, ['x' * 201]), "fake('{}\u2026)".format('x' * 198))
def test_dbg_signal(self): """Test dbg_signal().""" self.assertEqual(debug.dbg_signal(self.signal, [23, 42]), 'fake(23, 42)')
def test_dbg_signal_newline(signal): """Test dbg_signal() with a newline.""" dbg_signal = debug.dbg_signal(signal, ['foo\nbar']) assert dbg_signal == r"fake('foo\nbar')"
def test_dbg_signal_eliding(signal): """Test eliding in dbg_signal().""" dbg_signal = debug.dbg_signal(signal, ['x' * 201]) assert dbg_signal == "fake('{}\u2026)".format('x' * 198)
def test_dbg_signal(signal): """Test dbg_signal().""" assert debug.dbg_signal(signal, [23, 42]) == 'fake(23, 42)'