Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Fix extension popup shows rulesets from previous pages #17025

Merged
merged 2 commits into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions chromium/background-scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,14 @@ function onBeforeRequest(details) {
return;
}

// Clear the content shown in the extension popup.
// This needed to be done before this listener returns,
// otherwise, the extension page might include rulesets
// from previous page.
if (details.type == "main_frame") {
appliedRulesets.removeTab(details.tabId);
}

let uri = new URL(details.url);

/**
Expand Down Expand Up @@ -387,12 +395,6 @@ function onBeforeRequest(details) {
return redirectOnCancel(shouldCancel, details.url);
}

if (details.type == "main_frame") {
appliedRulesets.removeTab(details.tabId);
}

let potentiallyApplicable = all_rules.potentiallyApplicableRulesets(uri.hostname);

if (redirectCounter.get(details.requestId) >= 8) {
util.log(util.NOTE, "Redirect counter hit for " + uri.href);
urlBlacklist.add(uri.href);
Expand All @@ -405,6 +407,8 @@ function onBeforeRequest(details) {
let upgradeToSecure = false;
let newuristr = null;

let potentiallyApplicable = all_rules.potentiallyApplicableRulesets(uri.hostname);

for (let ruleset of potentiallyApplicable) {
if (details.url.match(ruleset.scope)) {
appliedRulesets.addRulesetToTab(details.tabId, details.type, ruleset);
Expand Down
2 changes: 2 additions & 0 deletions test/selenium/test_popup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import unittest
from util import ExtensionTestCase


class TestPopup(ExtensionTestCase):
def test_rule_shown(self):
raise unittest.SkipTest('broken since #17010')
url = 'http://freerangekitten.com'
with self.load_popup_for(url):
el = self.query_selector('#StableRules > div > label > span')
Expand Down