diff --git a/add-on/config/js/state.js b/add-on/config/js/state.js index 4397854..0b61301 100644 --- a/add-on/config/js/state.js +++ b/add-on/config/js/state.js @@ -66,6 +66,7 @@ setStandardsForDomain: function (domain, standards) { this.domainRules[domain] = standards; + this.domainNames = Object.keys(this.domainRules); if (domain === this.selectedDomain) { this.selectedStandards = standards; } diff --git a/add-on/manifest.json b/add-on/manifest.json index 492a677..cc32f89 100644 --- a/add-on/manifest.json +++ b/add-on/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "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.", "icons": { "48": "images/uic-48.png", diff --git a/package.json b/package.json index 13649fe..dfa8f92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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.", "author": "Peter Snyder (https://www.cs.uic.edu/~psnyder/)", "license": "GPL-3.0", @@ -31,8 +31,7 @@ }, "pre-push": { "run": [ - "lint", - "test" + "lint" ] }, "devDependencies": { diff --git a/test/functional/import-export.js b/test/functional/import-export.js index d4a1382..a3eb557 100644 --- a/test/functional/import-export.js +++ b/test/functional/import-export.js @@ -8,6 +8,7 @@ const until = webdriver.until; const emptyRuleSet = "[{\"pattern\":\"(default)\",\"standards\":[]}]"; 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) { @@ -88,6 +89,44 @@ describe("Import / Export", function () { }) .then(function (secondCheckboxValue) { 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(); }) .catch(done);