fix issue with the config page's state object falling out of sync when importing settings with new domains, fixes #26

This commit is contained in:
Peter Snyder 2017-10-28 16:52:40 -05:00
parent f0e9edaf31
commit 568b1ce602
4 changed files with 43 additions and 4 deletions

View file

@ -66,6 +66,7 @@
setStandardsForDomain: function (domain, standards) { setStandardsForDomain: function (domain, standards) {
this.domainRules[domain] = standards; this.domainRules[domain] = standards;
this.domainNames = Object.keys(this.domainRules);
if (domain === this.selectedDomain) { if (domain === this.selectedDomain) {
this.selectedStandards = standards; this.selectedStandards = standards;
} }

View file

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "WebAPI Manager", "name": "WebAPI Manager",
"version": "0.9.5", "version": "0.9.6",
"description": "Improves browser security and privacy by controlling page access to the Web API.", "description": "Improves browser security and privacy by controlling page access to the Web API.",
"icons": { "icons": {
"48": "images/uic-48.png", "48": "images/uic-48.png",

View file

@ -1,6 +1,6 @@
{ {
"name": "web-api-manager", "name": "web-api-manager",
"version": "0.9.5", "version": "0.9.6",
"description": "Tools to generate Web API managing browser extensions for Firefox and Chrome.", "description": "Tools to generate Web API managing browser extensions for Firefox and Chrome.",
"author": "Peter Snyder <psnyde2@uic.edu> (https://www.cs.uic.edu/~psnyder/)", "author": "Peter Snyder <psnyde2@uic.edu> (https://www.cs.uic.edu/~psnyder/)",
"license": "GPL-3.0", "license": "GPL-3.0",
@ -31,8 +31,7 @@
}, },
"pre-push": { "pre-push": {
"run": [ "run": [
"lint", "lint"
"test"
] ]
}, },
"devDependencies": { "devDependencies": {

View file

@ -8,6 +8,7 @@ const until = webdriver.until;
const emptyRuleSet = "[{\"pattern\":\"(default)\",\"standards\":[]}]"; const emptyRuleSet = "[{\"pattern\":\"(default)\",\"standards\":[]}]";
const blockingSVGandBeacon = "[{\"pattern\":\"(default)\",\"standards\":[\"Beacon\",\"Scalable Vector Graphics (SVG) 1.1 (Second Edition)\"]}]"; const blockingSVGandBeacon = "[{\"pattern\":\"(default)\",\"standards\":[\"Beacon\",\"Scalable Vector Graphics (SVG) 1.1 (Second Edition)\"]}]";
const newDomainImport = `[{"pattern":"*.example.com","standards":["Ambient Light Sensor API","WebGL Specification"]}]`;
const promiseOpenImportExportTab = function (driver) { const promiseOpenImportExportTab = function (driver) {
@ -88,6 +89,44 @@ describe("Import / Export", function () {
}) })
.then(function (secondCheckboxValue) { .then(function (secondCheckboxValue) {
assert.equal(secondCheckboxValue, utils.constants.svgBlockRule[0], "The second blocked standard should be the SVG standard."); assert.equal(secondCheckboxValue, utils.constants.svgBlockRule[0], "The second blocked standard should be the SVG standard.");
driverReference.close();
done();
})
.catch(done);
});
it("Importing rules for new domain", function (done) {
let driverReference;
let checkedCheckboxes;
utils.promiseGetDriver()
.then(function (driver) {
driverReference = driver;
return promiseOpenImportExportTab(driverReference);
})
.then(() => driverReference.findElement(by.css(".import-section textarea")).sendKeys(newDomainImport))
.then(() => driverReference.findElement(by.css(".import-section button")).click())
.then(() => utils.pause(500))
.then(() => driverReference.findElement(by.css("a[href='#domain-rules']")).click())
.then(() => driverReference.findElements(by.css("#domain-rules input[type='radio']")))
.then(function (radioElms) {
assert.equal(radioElms.length, 2, "There should be two domain rules in place.");
return radioElms[1].click();
})
.then(() => driverReference.findElements(by.css("#domain-rules input[type='checkbox']:checked")))
.then(function (checkboxElms) {
checkedCheckboxes = checkboxElms;
assert.equal(checkboxElms.length, 2, "There should be two standards blocked.");
return checkedCheckboxes[0].getAttribute("value");
})
.then(function (firstCheckboxValue) {
assert.equal(firstCheckboxValue, "Ambient Light Sensor API", "The first blocked standard should be 'Ambient Light Sensor API'.");
return checkedCheckboxes[1].getAttribute("value");
})
.then(function (secondCheckboxValue) {
assert.equal(secondCheckboxValue, "WebGL Specification", "The second blocked standard should be 'WebGL Specification'.");
driverReference.close();
done(); done();
}) })
.catch(done); .catch(done);