示例#1
0
    def test_cookie_tracker_detection(self):
        """Tests basic cookie tracking. The tracking site has no DNT file,
        and gets blocked by PB.

        Visits three sites, all of which have an iframe that points to a fourth site
        that reads and writes a cookie. The third party cookie will be picked up by
        PB after each of the site loads, but no action will be taken. Then the first
        site will be reloaded, and the UI will show the third party cookie as blocked."""

        self.driver.delete_all_cookies()
        # fixme: check for chrome settings for third party cookies?

        # load the first site with the third party code that reads and writes a cookie
        self.load_url(SITE1_URL)
        self.load_pb_ui(SITE1_URL)
        self.get_tracker_state()
        self.assertTrue(THIRD_PARTY_TRACKER in self.nonTrackers)

        # go to second site
        self.load_url(SITE2_URL)
        window_utils.close_windows_with_url(self.driver, SITE1_URL)
        self.load_pb_ui(SITE2_URL)
        self.get_tracker_state()
        self.assertTrue(THIRD_PARTY_TRACKER in self.nonTrackers)

        # go to third site
        self.load_url(SITE3_URL)
        window_utils.close_windows_with_url(self.driver, SITE2_URL)
        self.load_pb_ui(SITE3_URL)
        self.get_tracker_state()
        self.assertTrue(THIRD_PARTY_TRACKER in self.nonTrackers)

        # reloading the first site should now cause the cookie to be blocked
        # it can take a long time for the UI to be updated, so retry a number of
        # times before giving up. See bug #702.
        print(
            "this is checking for a dnt file at a site without https, so we'll just have to wait for the connection to timeout before we proceed"
        )
        self.load_url(SITE1_URL)
        window_utils.close_windows_with_url(self.driver, SITE3_URL)
        for i in range(60):
            self.load_pb_ui(SITE1_URL)
            self.get_tracker_state()

            if THIRD_PARTY_TRACKER in self.cookieBlocked:
                print("Popup UI has been updated. Yay!")
                break
            window_utils.close_windows_with_url(self.driver, self.popup_url)
            window_utils.close_windows_with_url(self.driver, self.popup_url)
            print("popup UI has not been updated yet. try again in 10 seconds")
            time.sleep(10)

        self.assertTrue(THIRD_PARTY_TRACKER in self.cookieBlocked)
示例#2
0
    def test_cookie_tracker_detection(self):
        """Tests basic cookie tracking. The tracking site has no DNT file,
        and gets blocked by PB.

        Visits three sites, all of which have an iframe that points to a fourth site
        that reads and writes a cookie. The third party cookie will be picked up by
        PB after each of the site loads, but no action will be taken. Then the first
        site will be reloaded, and the UI will show the third party cookie as blocked."""

        self.driver.delete_all_cookies()
        # fixme: check for chrome settings for third party cookies?

        self.wait_for_script(
            "return typeof chrome != 'undefined' && chrome && chrome.extension"
        )
        self.js(
            "chrome.extension.getBackgroundPage()."
            "badger.getSettings().setItem('showNonTrackingDomains', true);")

        # load the first site with the third party code that reads and writes a cookie
        self.load_url(SITE1_URL)
        self.load_pb_ui(SITE1_URL)
        self.get_tracker_state()
        self.assertTrue(THIRD_PARTY_TRACKER in self.nonTrackers)

        # go to second site
        self.load_url(SITE2_URL)
        window_utils.close_windows_with_url(self.driver, SITE1_URL)
        self.load_pb_ui(SITE2_URL)
        self.get_tracker_state()
        self.assertTrue(THIRD_PARTY_TRACKER in self.nonTrackers)

        # go to third site
        self.load_url(SITE3_URL)
        window_utils.close_windows_with_url(self.driver, SITE2_URL)
        self.load_pb_ui(SITE3_URL)
        self.get_tracker_state()
        self.assertTrue(THIRD_PARTY_TRACKER in self.nonTrackers)

        # reloading the first site should now cause the cookie to be blocked
        # it can take a long time for the UI to be updated, so retry a number of
        # times before giving up. See bug #702.
        #
        # this is checking for a dnt file at a site without https, so we'll
        # just have to wait for the connection to time out before we proceed
        self.load_url(SITE1_URL)
        window_utils.close_windows_with_url(self.driver, SITE3_URL)
        for _ in range(5):
            self.load_pb_ui(SITE1_URL)
            self.get_tracker_state()

            if THIRD_PARTY_TRACKER in self.cookieBlocked:
                # Popup UI has been updated. Yay!
                break
            window_utils.close_windows_with_url(self.driver, self.popup_url)
            print("popup UI has not been updated yet. retrying ...")
            time.sleep(3)

        self.assertTrue(THIRD_PARTY_TRACKER in self.cookieBlocked)
    def test_cookie_tracker_detection(self):
	"""Tests basic cookie tracking. The tracking site has no DNT file,
	and gets blocked by PB.

	Visits three sites, all of which have an iframe that points to a fourth site
	that reads and writes a cookie. The third party cookie will be picked up by
	PB after each of the site loads, but no action will be taken. Then the first 
	site will be reloaded, and the UI will show the third party cookie as blocked."""

	self.driver.delete_all_cookies()
	# fixme: check for chrome settings for third party cookies?

	# load the first site with the third party code that reads and writes a cookie
        self.load_url( PB_CHROME_SITE1_URL )
	window_utils.close_windows_with_url( self.driver, PB_CHROME_FR_URL )
	self.load_pb_ui( PB_CHROME_SITE1_URL )
	self.get_tracker_state()
	self.assertTrue( self.nonTrackers.has_key( PB_CHROME_THIRD_PARTY_TRACKER ) )

	# go to second site
        self.load_url( PB_CHROME_SITE2_URL )
	window_utils.close_windows_with_url( self.driver, PB_CHROME_SITE1_URL )
	self.load_pb_ui( PB_CHROME_SITE2_URL )
	self.get_tracker_state()
	self.assertTrue( self.nonTrackers.has_key( PB_CHROME_THIRD_PARTY_TRACKER ) )

	# go to third site
        self.load_url( PB_CHROME_SITE3_URL )
	window_utils.close_windows_with_url( self.driver, PB_CHROME_SITE2_URL )
	self.load_pb_ui( PB_CHROME_SITE3_URL )
	self.get_tracker_state()
	self.assertTrue( self.nonTrackers.has_key( PB_CHROME_THIRD_PARTY_TRACKER ) )

	# reloading the first site should now cause the cookie to be blocked
	# it can take a long time for the UI to be updated, so retry a number of
	# times before giving up. See bug #702.
	print "this is checking for a dnt file at a site without https, so we'll just have to wait for the connection to timeout before we proceed"
        self.load_url( PB_CHROME_SITE1_URL )
	window_utils.close_windows_with_url( self.driver, PB_CHROME_SITE3_URL )
	for i in range(60):
		self.load_pb_ui( PB_CHROME_SITE1_URL )
		self.get_tracker_state()
		if self.cookieBlocked.has_key( PB_CHROME_THIRD_PARTY_TRACKER ):
			print "Popup UI has been updated. Yay!"
			break
		window_utils.close_windows_with_url( self.driver, PB_CHROME_PU_URL )
		print "popup UI has not been updated yet. try again in 10 seconds"
		time.sleep(10)
	self.assertTrue( self.cookieBlocked.has_key( PB_CHROME_THIRD_PARTY_TRACKER ) )
示例#4
0
    def test_cookie_tracker_detection(self):
        """Tests basic cookie tracking. The tracking site has no DNT file,
        and gets blocked by PB.

        Visits three sites, all of which have an iframe that points to a fourth site
        that reads and writes a cookie. The third party cookie will be picked up by
        PB after each of the site loads, but no action will be taken. Then the first
        site will be reloaded, and the UI will show the third party cookie as blocked."""

        self.driver.delete_all_cookies()
        # fixme: check for chrome settings for third party cookies?

        self.js(
            "chrome.extension.getBackgroundPage()."
            "badger.getSettings().setItem('showNonTrackingDomains', true);"
        )

        # load the first site with the third party code that reads and writes a cookie
        self.load_url(SITE1_URL)
        self.load_pb_ui(SITE1_URL)
        self.get_tracker_state()
        self.assertTrue(THIRD_PARTY_TRACKER in self.nonTrackers)

        # go to second site
        self.load_url(SITE2_URL)
        window_utils.close_windows_with_url(self.driver, SITE1_URL)
        self.load_pb_ui(SITE2_URL)
        self.get_tracker_state()
        self.assertTrue(THIRD_PARTY_TRACKER in self.nonTrackers)

        # go to third site
        self.load_url(SITE3_URL)
        window_utils.close_windows_with_url(self.driver, SITE2_URL)
        self.load_pb_ui(SITE3_URL)
        self.get_tracker_state()
        self.assertTrue(THIRD_PARTY_TRACKER in self.nonTrackers)

        # reloading the first site should now cause the cookie to be blocked
        # it can take a long time for the UI to be updated, so retry a number of
        # times before giving up. See bug #702.
        #
        # this is checking for a dnt file at a site without https, so we'll
        # just have to wait for the connection to time out before we proceed
        self.load_url(SITE1_URL)
        window_utils.close_windows_with_url(self.driver, SITE3_URL)
        for _ in range(5):
            self.load_pb_ui(SITE1_URL)
            self.get_tracker_state()

            if THIRD_PARTY_TRACKER in self.cookieBlocked:
                # Popup UI has been updated. Yay!
                break
            window_utils.close_windows_with_url(self.driver, self.popup_url)
            print("popup UI has not been updated yet. retrying ...")
            time.sleep(3)

        self.assertTrue(THIRD_PARTY_TRACKER in self.cookieBlocked)