How to use the thug.DOM.JSClass.JSClass function in thug

To help you get started, we’ve selected a few thug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github buffer / thug / thug / DOM / Console.py View on Github external
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA

import logging

from .JSClass import JSClass

log = logging.getLogger("Thug")


class Console(JSClass):
    def __init__(self):
        self._counter = 0
        self._label_counter = dict()
        self.__init_console_personality()

    def __init_console_personality(self):
        if log.ThugOpts.Personality.isIE():
            self.__init_console_personality_IE()
            return

        if log.ThugOpts.Personality.isFirefox():
            self.__init_console_personality_Firefox()
            return

        if log.ThugOpts.Personality.isChrome():
            self.__init_console_personality_Chrome()
github buffer / thug / thug / DOM / JSClass.py View on Github external
class JSClassConstructor(JSClass):
    def __init__(self, cls):
        self.cls = cls

    @property
    def name(self):
        return self.cls.__name__

    def toString(self):
        return "function %s() {\n  [native code]\n}" % self.name

    def __call__(self, *args, **kwds):
        return self.cls(*args, **kwds)


class JSClassPrototype(JSClass):
    def __init__(self, cls):
        self.cls = cls

    @property
    def constructor(self):
        return JSClassConstructor(self.cls)

    @property
    def name(self):
        return self.cls.__name__
github buffer / thug / thug / DOM / Components.py View on Github external
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA

from .JSClass import JSClass
from .Utils import Utils


class Components(JSClass):
    def __init__(self):
        self.utils = Utils()
github buffer / thug / thug / DOM / Crypto.py View on Github external
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA

from .JSClass import JSClass


class Crypto(JSClass):
    def __init__(self):
        pass

    @property
    def enableSmartCardEvents(self):
        return False

    @property
    def version(self):
        return "2.4"

    def disableRightClick(self):
        pass

    def importUserCertificates(self, nickname, cmmfResponse, forceToBackUp):
        return ""
github buffer / thug / thug / DOM / Chrome.py View on Github external
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA

from .JSClass import JSClass
from .WebStore import WebStore


class Chrome(JSClass):
    def __init__(self):
        self.webstore = WebStore()

    def __str__(self):
        return "[object Object]"
github buffer / thug / thug / DOM / UserProfile.py View on Github external
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA

from .JSClass import JSClass


class UserProfile(JSClass):
    vCardSchemas = ("vCard.Business.City",
                    "vCard.Business.Country",
                    "vCard.Business.Fax",
                    "vCard.Business.Phone",
                    "vCard.Business.State",
                    "vCard.Business.StreetAddress",
                    "vCard.Business.URL",
                    "vCard.Business.Zipcode",
                    "vCard.Cellular",
                    "vCard.Company",
                    "vCard.Department",
                    "vCard.DisplayName",
                    "vCard.Email",
                    "vCard.FirstName",
                    "vCard.Gender",
                    "vCard.Home.City",
github buffer / thug / thug / DOM / Location.py View on Github external
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA

import logging
import six.moves.urllib.parse as urlparse

from thug.DOM.W3C import w3c

from .DFT import DFT
from .JSClass import JSClass

log = logging.getLogger("Thug")


class Location(JSClass):
    def __init__(self, window):
        self._window = window

    def toString(self): # pragma: no cover
        return self._window.url

    @property
    def parts(self):
        return urlparse.urlparse(self._window.url)

    def get_href(self):
        return self._window.url

    def set_href(self, url):
        from .Window import Window
github buffer / thug / thug / DOM / W3C / Events / Event.py View on Github external
#!/usr/bin/env python

from thug.DOM.JSClass import JSClass

import logging

log = logging.getLogger("Thug")


# Introduced in DOM Level 2
class Event(JSClass):
    CAPTURING_PHASE     = 1  # The current event phase is the capturing phase.
    AT_TARGET           = 2  # The event is currently being evaluated at the target EventTarget
    BUBBLING_PHASE      = 3  # The current event phase is the bubbling phase.

    def __init__(self):
        self._type               = None
        self._target             = None
        self.currentTarget       = None
        self.eventPhase          = self.AT_TARGET
        self._stoppedPropagation = False
        self._defaultPrevented   = False
        self._canBubble          = False
        self._cancelable         = False

        self.__init_event_personality()
github buffer / thug / thug / DOM / W3C / Events / EventException.py View on Github external
#!/usr/bin/env python

from thug.DOM.JSClass import JSClass


# Introduced in DOM Level 2
class EventException(RuntimeError, JSClass):
    UNSPECIFIED_EVENT_TYPE_ERR = 0  # If the Event's type was not specified by initializing the event before the
                                    # method was called. Specification of the Event's type as null or an empty
                                    # string will also trigger this exception.

    def __init__(self, code):
        self.code = code
github buffer / thug / thug / DOM / W3C / Core / ClassList.py View on Github external
#!/usr/bin/env python

import logging

from thug.DOM.JSClass import JSClass

log = logging.getLogger("Thug")


class ClassList(JSClass):
    def __init__(self, tag):
        self.tag = tag
        self.__init_classlist_personality()
        self.__init_class_list()

    def __init_classlist_personality(self):
        if log.ThugOpts.Personality.isIE():
            self.__init_classlist_personality_IE()
            return

        if log.ThugOpts.Personality.isFirefox():
            self.__init_classlist_personality_Firefox()
            return

        if log.ThugOpts.Personality.isChrome():
            self.__init_classlist_personality_Chrome()