def test_CssPrecedence(self): elem = PyQuery( '<iframe width="10" height="20" style="width: 30px; height: 40px;"></iframe>' ) width = self.analyzer.getDimension(elem, 'width') height = self.analyzer.getDimension(elem, 'height') self.assertEqual(width, 30) self.assertEqual(height, 40)
def test_CorrectExtension(self): elem = PyQuery('<script src="src.js"></script>') result = self.analyzer.hasWrongExtension(elem) self.assertFalse(result)
def test_KnownElement(self): elem = PyQuery('<html></html>') result = self.analyzer.isUnknownElement(elem) self.assertFalse(result)
def test_UnsuspiciousObject(self): elem = PyQuery( '<object classid="clsid:AE7AB96B-FF5E-4dce-801E-14DF2C4CD681"></object>' ) result = self.analyzer.isSuspiciousObject(elem) self.assertEqual(result, False)
def test_LargeHeight(self): elem = PyQuery('<iframe style="height: 20px"></iframe>') result = self.analyzer.isSmall(elem) self.assertFalse(result)
def test_SmallWidth(self): elem = PyQuery('<iframe style="width: 1px"></iframe>') result = self.analyzer.isSmall(elem) self.assertTrue(result)
def test_NoHiddenStyles(self): elem = PyQuery('<div style="color: red;"></div>') result = self.analyzer.isHidden(elem) self.assertFalse(result)
def test_CssFloat(self): elem = PyQuery('<iframe style="width: 70.5;"></iframe>') result = self.analyzer.getDimension(elem, 'width') self.assertEqual(result, 70.5)
def test_MetaWithRefresh(self): elem = PyQuery('<meta http-equiv="refresh"></meta>') result = self.analyzer.isMetaRefresh(elem) self.assertTrue(result)
def test_NoStyle(self): elem = PyQuery('<div></div>') result = self.analyzer.isHidden(elem) self.assertFalse(result)
def test_MetaWithHttpEquivAttribute(self): elem = PyQuery('<meta http-equiv="content-type"></meta>') result = self.analyzer.isMetaRefresh(elem) self.assertFalse(result)
def test_MetaNoRefresh(self): elem = PyQuery('<meta></meta>') result = self.analyzer.isMetaRefresh(elem) self.assertFalse(result)
def test_WrongExtension(self): elem = PyQuery('<script src="src.exe"></script>') result = self.analyzer.hasWrongExtension(elem) self.assertTrue(result)
def test_CssExtraSpaces(self): elem = PyQuery('<iframe style=" width : 50px "></iframe>') result = self.analyzer.getDimension(elem, 'width') self.assertEqual(result, 50)
def test_DisplayNone(self): elem = PyQuery('<div style="display: none;"></div>') result = self.analyzer.isHidden(elem) self.assertTrue(result)
def test_CssNoPx(self): elem = PyQuery('<iframe style="width: 60;"></iframe>') result = self.analyzer.getDimension(elem, 'width') self.assertEqual(result, 60)
def test_ExtraSpaces(self): elem = PyQuery('<div style=" display : none "></div>') result = self.analyzer.isHidden(elem) self.assertTrue(result)
def test_NoDimensions(self): elem = PyQuery('<iframe></iframe>') result = self.analyzer.isSmall(elem) self.assertFalse(result)
def test_VisibilityHidden(self): elem = PyQuery('<div style="visibility: hidden;"></div>') result = self.analyzer.isHidden(elem) self.assertTrue(result)
def test_SmallArea(self): elem = PyQuery('<iframe style="width: 3px; height: 3px"></iframe>') result = self.analyzer.isSmall(elem) self.assertTrue(result)
def test_widthAttr(self): elem = PyQuery('<iframe width="10"></iframe>') result = self.analyzer.getDimension(elem, 'width') self.assertEqual(result, 10)
def test_SmallHeight(self): elem = PyQuery('<iframe style="height: 1px"></iframe>') result = self.analyzer.isSmall(elem) self.assertTrue(result)
def test_heightAttr(self): elem = PyQuery('<iframe height="20"></iframe>') result = self.analyzer.getDimension(elem, 'height') self.assertEqual(result, 20)
def test_UnknownElement(self): elem = PyQuery('<invalidElement></invalidElement>') result = self.analyzer.isUnknownElement(elem) self.assertTrue(result)
def test_CssHeight(self): elem = PyQuery('<iframe style="height: 40px;"></iframe>') result = self.analyzer.getDimension(elem, 'height') self.assertEqual(result, 40)
def test_SuspiciousObject(self): elem = PyQuery( '<object classid="clsid:CA8A9780-280D-11CF-A24D-444553540000"></object>' ) result = self.analyzer.isSuspiciousObject(elem) self.assertEqual(result, True)
def test_InlineScript(self): elem = PyQuery('<script>alert("abc")</script>') result = self.analyzer.hasWrongExtension(elem) self.assertFalse(result)