Example #1
0
    def tearDown(self):
        if self.objPython != list(asSeq(self.ctx.globalObject.objJS)):
            self.fail("Python object %s differs from JavaScript object %s" % \
                          (repr(self.objPython),
                           repr(list(self.ctx.globalObject.objJS))))

        TestCaseWithContext.tearDown(self)
Example #2
0
    def tearDown(self):
        if self.objPython != list(asSeq(self.ctx.globalObject.objJS)):
            self.fail("Python object %s differs from JavaScript object %s" % \
                          (repr(self.objPython),
                           repr(list(self.ctx.globalObject.objJS))))

        TestCaseWithContext.tearDown(self)
Example #3
0
    def load_finished_cb(self, view, frame):
        print "load_finished"

        # Retrieve the JavaScript context from the browser widget.
        ctx = jscore.JSContext(self.webView.get_main_frame().get_global_context())

        # Retrieve the JavaScript window object.
        window = ctx.globalObject.window

        # Alert works!
        #window.alert("This is an alert")

        # We can change properties in the window object.
        window.foo = 'bar'
        assert ctx.evaluateScript("window.foo") == 'bar'

        # Retrieve the DOM document object.
        document = ctx.globalObject.document

        # Document title.
        print "Title:", document.title
        form = document.forms[0]

        # List all A (anchor) tags.
        atags = document.getElementsByTagName("a")
        print atags.__class__.__name__
        print list(atags.iterkeys())
        for a in jscore.asSeq(atags):
            print a.href
    def load_finished_cb(self, view, frame):
        print "load_finished"

        # Retrieve the JavaScript context from the browser widget.
        ctx = jscore.JSContext(self.webView.get_main_frame().get_global_context())

        # Retrieve the JavaScript window object.
        window = ctx.globalObject.window

        # Alert works!
        # window.alert("This is an alert")

        # We can change properties in the window object.
        window.foo = "bar"
        assert ctx.evaluateScript("window.foo") == "bar"

        # Retrieve the DOM document object.
        document = ctx.globalObject.document

        # Document title.
        print "Title:", document.title
        form = document.forms[0]

        # List all A (anchor) tags.
        atags = document.getElementsByTagName("a")
        print atags.__class__.__name__
        print list(atags.iterkeys())
        for a in jscore.asSeq(atags):
            print a.href
Example #5
0
 def testContains4(self):
     obj =  asSeq(self.ctx.evaluateScript("""
       (['a', 'b', 'c', 'd', 'e'])
       """))
     self.assertTrue('a' in obj)
     self.assertTrue('c' in obj)
     self.assertTrue('e' in obj)
     self.assertFalse('f' in obj)
     self.assertFalse(1 in obj)
     self.assertFalse(None in obj)
Example #6
0
 def testContains4(self):
     obj = asSeq(
         self.ctx.evaluateScript("""
       (['a', 'b', 'c', 'd', 'e'])
       """))
     self.assertTrue('a' in obj)
     self.assertTrue('c' in obj)
     self.assertTrue('e' in obj)
     self.assertFalse('f' in obj)
     self.assertFalse(1 in obj)
     self.assertFalse(None in obj)
Example #7
0
 def testIter1(self):
     self.ctx.evaluateScript("""
         i = 0;
         props = [];
         for (prop in objPython) {
             if (objPython.hasOwnProperty(prop)) {
                 props[i] = prop;
             }
             i++;
         }""")
     self.assertEqual(sorted(self.objPython),
                      sorted(asSeq(self.ctx.globalObject.props)))
Example #8
0
 def testIter1(self):
     self.ctx.evaluateScript("""
         i = 0;
         props = [];
         for (prop in objPython) {
             if (objPython.hasOwnProperty(prop)) {
                 props[i] = prop;
             }
             i++;
         }""")
     self.assertEqual(sorted(self.objPython),
                      sorted(asSeq(self.ctx.globalObject.props)))
Example #9
0
 def setUp(self):
     TestCaseWithContext.setUp(self)
     self.obj = asSeq(
         self.ctx.evaluateScript("""
       ([1, 2, 3, 4, 5])
       """))
Example #10
0
 def testContains5(self):
     obj = asSeq(self.ctx.evaluateScript("""[]"""))
     self.assertFalse('f' in obj)
     self.assertFalse(1 in obj)
     self.assertFalse(None in obj)
Example #11
0
 def testAsSeq2(self):
     self.assertEqual(self.obj.length, 5)
     asSeq(self.obj).append(6)
     self.assertEqual(self.obj.length, 6)
Example #12
0
 def testAsSeq1(self):
     s1 = asSeq(self.obj)
     s2 = asSeq(self.obj)
     self.assertTrue(s1 is s2)
Example #13
0
 def setUp(self):
     TestCaseWithContext.setUp(self)
     self.obj = asSeq(self.ctx.evaluateScript("""
       ([1, 2, 3, 4, 5])
       """))
Example #14
0
 def testContains5(self):
     obj =  asSeq(self.ctx.evaluateScript("""[]"""))
     self.assertFalse('f' in obj)
     self.assertFalse(1 in obj)
     self.assertFalse(None in obj)
Example #15
0
 def testAsSeq2(self):
     self.assertEqual(self.obj.length, 5)
     asSeq(self.obj).append(6)
     self.assertEqual(self.obj.length, 6)
Example #16
0
 def testAsSeq1(self):
     s1 = asSeq(self.obj)
     s2 = asSeq(self.obj)
     self.assertTrue(s1 is s2)