Esempio n. 1
0
    def test_all_property_transfer(self):
        """
        Test 3: Initial property transfer - make sure the viewer gets stuff set.
        """
        self.init_webdriver()

        # Replicate the initial test
        self.test_init_html()

        # Now let's go further and modify the document
        self.webdriver.execute_script("""
            broadcaster_iframe.contentWindow.change_some_css();
        """)

        # Change text input value property
        new_input_value = "dfkjgopi"
        self.webdriver.switch_to_frame('broadcaster_iframe')
        input = self.webdriver.find_element_by_id('thetextinput')
        input.send_keys(new_input_value)

        self.webdriver.switch_to_default_content()
        diff = self.execute_script("""
            var data = broadcaster.start_document();
            return JSON.stringify(data["props"]);
        """)
        diff = json.loads(diff)

        # Only properties
        assert all(d[0] == "props" for d in diff)
        assert util.diff_contains_changed_property_key(diff, "value")

        # Should be a border in there somewhere (note: IE returns individual
        # border rules for each side, FF retains the single border rule)
        assert util.diff_contains_changed_property_value(diff, "purple")

        diff = sanitise_diffs(diff)

        # We can reuse test 2's diff apply thing
        self.apply_viewer_diff(diff)

        # Verify the diff made it through
        self.webdriver.switch_to_frame('viewer_iframe')
        input = self.webdriver.find_element_by_id('thetextinput')
        input_value = input.get_attribute("value")
        print "Got input value: %s. Expected: <original value>%s" % (
            input_value, new_input_value)
        assert input_value.endswith(new_input_value)
        table = self.webdriver.find_element_by_id('thetable')
        table_background_colour = input.value_of_css_property(
            "background-color")
        table_background_colour = table_background_colour.replace(" ", "")
        assert table_background_colour in ("purple", "rgba(255,255,255,1)")
Esempio n. 2
0
    def test_all_property_transfer(self):
        """
        Test 3: Initial property transfer - make sure the viewer gets stuff set.
        """
        self.init_webdriver()

        # Replicate the initial test
        self.test_init_html()

        # Now let's go further and modify the document
        self.webdriver.execute_script("""
            broadcaster_iframe.contentWindow.change_some_css();
        """)

        # Change text input value property
        new_input_value = "dfkjgopi"
        self.webdriver.switch_to_frame('broadcaster_iframe')
        input = self.webdriver.find_element_by_id('thetextinput')
        input.send_keys(new_input_value)

        self.webdriver.switch_to_default_content()
        diff = self.execute_script("""
            var data = broadcaster.start_document();
            return JSON.stringify(data["props"]);
        """)
        diff = json.loads(diff)

        # Only properties
        assert all(d[0] == "props" for d in diff)
        assert util.diff_contains_changed_property_key(diff, "value")

        # Should be a border in there somewhere (note: IE returns individual
        # border rules for each side, FF retains the single border rule)
        assert util.diff_contains_changed_property_value(diff, "purple")

        diff = sanitise_diffs(diff)

        # We can reuse test 2's diff apply thing
        self.apply_viewer_diff(diff)

        # Verify the diff made it through
        self.webdriver.switch_to_frame('viewer_iframe')
        input = self.webdriver.find_element_by_id('thetextinput')
        input_value = input.get_attribute("value")
        print "Got input value: %s. Expected: <original value>%s" % (input_value, new_input_value)
        assert input_value.endswith(new_input_value)
        table = self.webdriver.find_element_by_id('thetable')
        table_background_colour = input.value_of_css_property("background-color")
        table_background_colour = table_background_colour.replace(" ", "")
        assert table_background_colour in ("purple", "rgba(255,255,255,1)")
    def test_get_diff_properties(self):
        """ Test 8: Diff of properties """
        self.init_webdriver()
        self.init_broadcaster_state()

        new_value = "-ae9ij"

        # Change text input value
        self.webdriver.switch_to_frame('broadcaster_iframe')
        input = self.webdriver.find_element_by_id('thetextinput')
        input.send_keys(new_value)
        #self.execute_script("test_8_modify_broadcaster_document_with_property()")

        # Get the diff
        self.webdriver.switch_to_default_content()
        result = self.get_broadcaster_diff()
        print result

        # Should be there
        assert util.diff_contains_changed_property_value(result, new_value)
    def test_get_initial_property_diff(self):
        """ Test 5: Retrieve initial property diff """
        self.init_webdriver()
        result = self.execute_script("""
            var data = broadcaster.start_document();
            return JSON.stringify(data["props"]);
        """)
        result = json.loads(result)
        print result

        # CSS rules only
        assert all(d[0] == "props" for d in result)

        # Should be a border in there somewhere (note: IE returns individual
        # border rules for each side, FF retains the single border rule)
        assert util.diff_contains_changed_property_value(result, "border")

        # Make sure there's no crud making it through
        assert not util.diff_contains_empty_attr_prop_values(result)

        # One inline style has been defined against the table, there should be
        # a "value" property against the input element as well
        assert len(result) >= 1