From 25699671879812bb1082a053ead1159e497fca09 Mon Sep 17 00:00:00 2001 From: John Gruen Date: Mon, 17 Jul 2017 19:36:02 +0200 Subject: [PATCH 1/3] set dimensions for icon and add to startup (#3136) --- addon/webextension/background/startBackground.js | 2 +- addon/webextension/icons/icon-starred-32-v2.svg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/webextension/background/startBackground.js b/addon/webextension/background/startBackground.js index 8544542c82..04397efeb4 100644 --- a/addon/webextension/background/startBackground.js +++ b/addon/webextension/background/startBackground.js @@ -55,7 +55,7 @@ this.startBackground = (function() { browser.storage.local.get(["hasSeenOnboarding"]).then((result) => { let hasSeenOnboarding = !!result.hasSeenOnboarding; if (!hasSeenOnboarding) { - let path = "icons/icon-starred-32.svg"; + let path = "icons/icon-starred-32-v2.svg"; browser.browserAction.setIcon({path}); } }).catch((error) => { diff --git a/addon/webextension/icons/icon-starred-32-v2.svg b/addon/webextension/icons/icon-starred-32-v2.svg index eecdb63a4b..d359f03ca1 100644 --- a/addon/webextension/icons/icon-starred-32-v2.svg +++ b/addon/webextension/icons/icon-starred-32-v2.svg @@ -1 +1 @@ -icon copy 2-32 +icon-starred-32-v2 From f0aa032bfd09a1a6eb0f975f1e56cad6ebe8ea38 Mon Sep 17 00:00:00 2001 From: Jared Hirsch Date: Mon, 17 Jul 2017 15:28:36 -0700 Subject: [PATCH 2/3] Address 10.6 review comments (bug 1381132) --- ...nkDocumentUrl.js => assertIsBlankDocument.js} | 6 +++--- addon/webextension/background/selectorLoader.js | 2 +- addon/webextension/clipboard.js | 13 ++++++------- addon/webextension/onboarding/slides.js | 9 ++++----- addon/webextension/selector/ui.js | 16 +++++++--------- 5 files changed, 21 insertions(+), 25 deletions(-) rename addon/webextension/{assertIsBlankDocumentUrl.js => assertIsBlankDocument.js} (58%) diff --git a/addon/webextension/assertIsBlankDocumentUrl.js b/addon/webextension/assertIsBlankDocument.js similarity index 58% rename from addon/webextension/assertIsBlankDocumentUrl.js rename to addon/webextension/assertIsBlankDocument.js index 40016bdee1..3df0b37b59 100644 --- a/addon/webextension/assertIsBlankDocumentUrl.js +++ b/addon/webextension/assertIsBlankDocument.js @@ -2,10 +2,10 @@ Should be applied *inside* catcher.watchFunction */ -this.assertIsBlankDocumentUrl = function assertIsBlankDocumentUrl(documentUrl) { - if (documentUrl !== browser.extension.getURL("blank.html")) { +this.assertIsBlankDocument = function assertIsBlankDocument(doc) { + if (doc.documentURI !== browser.extension.getURL("blank.html")) { let exc = new Error('iframe URL does not match expected blank.html'); - exc.foundURL = documentUrl; + exc.foundURL = doc.documentURI; throw exc; } } diff --git a/addon/webextension/background/selectorLoader.js b/addon/webextension/background/selectorLoader.js index 46ce74543a..3fdc8ee498 100644 --- a/addon/webextension/background/selectorLoader.js +++ b/addon/webextension/background/selectorLoader.js @@ -14,7 +14,7 @@ this.selectorLoader = (function() { "log.js", "catcher.js", "assertIsTrusted.js", - "assertIsBlankDocumentUrl.js", + "assertIsBlankDocument.js", "background/selectorLoader.js", "selector/callBackground.js", "selector/util.js" diff --git a/addon/webextension/clipboard.js b/addon/webextension/clipboard.js index 00f752ef2a..140e143fff 100644 --- a/addon/webextension/clipboard.js +++ b/addon/webextension/clipboard.js @@ -1,4 +1,4 @@ -/* globals catcher, assertIsBlankDocumentUrl */ +/* globals catcher, assertIsBlankDocument */ "use strict"; @@ -14,11 +14,10 @@ this.clipboard = (function() { element.style.opacity = "0"; element.style.width = "1px"; element.style.height = "1px"; - element.onload = catcher.watchFunction(() => { + element.addEventListener("load", catcher.watchFunction(() => { try { - element.onload = null; let doc = element.contentDocument; - assertIsBlankDocumentUrl(doc.URL); + assertIsBlankDocument(doc); let el = doc.createElement("textarea"); doc.body.appendChild(el); el.value = text; @@ -27,12 +26,12 @@ this.clipboard = (function() { if (!copied) { catcher.unhandled(new Error("Clipboard copy failed")); } - doc.body.removeChild(el); + el.remove(); resolve(copied); } finally { - document.body.removeChild(element); + element.remove(); } - }); + }), {once: true}); document.body.appendChild(element); }); }; diff --git a/addon/webextension/onboarding/slides.js b/addon/webextension/onboarding/slides.js index cc1b4ec0d8..064cace2c6 100644 --- a/addon/webextension/onboarding/slides.js +++ b/addon/webextension/onboarding/slides.js @@ -1,4 +1,4 @@ -/* globals log, catcher, onboardingHtml, onboardingCss, util, shooter, callBackground, assertIsTrusted, assertIsBlankDocumentUrl */ +/* globals log, catcher, onboardingHtml, onboardingCss, util, shooter, callBackground, assertIsTrusted, assertIsBlankDocument */ "use strict"; @@ -35,10 +35,9 @@ this.slides = (function() { html = html.replace(/MOZ_EXTENSION([^\"]+)/g, (match, filename) => { return browser.extension.getURL(filename); }); - iframe.onload = catcher.watchFunction(() => { - iframe.onload = null; + iframe.addEventListener("load", catcher.watchFunction(() => { doc = iframe.contentDocument; - assertIsBlankDocumentUrl(doc.URL); + assertIsBlankDocument(doc); let parsedDom = (new DOMParser()).parseFromString( html, "text/html" @@ -53,7 +52,7 @@ this.slides = (function() { localizeText(doc); activateSlide(doc); resolve(); - }); + }), {once: true}); document.body.appendChild(iframe); iframe.focus(); window.addEventListener("resize", onResize); diff --git a/addon/webextension/selector/ui.js b/addon/webextension/selector/ui.js index 6a7574462b..ce37dcad7a 100644 --- a/addon/webextension/selector/ui.js +++ b/addon/webextension/selector/ui.js @@ -1,4 +1,4 @@ -/* globals log, util, catcher, inlineSelectionCss, callBackground, assertIsTrusted, assertIsBlankDocumentUrl */ +/* globals log, util, catcher, inlineSelectionCss, callBackground, assertIsTrusted, assertIsBlankDocument */ "use strict"; @@ -92,10 +92,9 @@ this.ui = (function() { // eslint-disable-line no-unused-vars this.element.style.margin = "0"; this.element.scrolling = "no"; this.updateElementSize(); - this.element.onload = watchFunction(() => { - this.element.onload = null; + this.element.addEventListener("load", watchFunction(() => { this.document = this.element.contentDocument; - assertIsBlankDocumentUrl(this.document.URL); + assertIsBlankDocument(this.document); this.document.documentElement.innerHTML = ` @@ -109,7 +108,7 @@ this.ui = (function() { // eslint-disable-line no-unused-vars this.document.documentElement.dir = browser.i18n.getMessage("@@bidi_dir"); this.document.documentElement.lang = browser.i18n.getMessage("@@ui_locale"); resolve(); - }); + }), {once: true}); document.body.appendChild(this.element); } else { resolve(); @@ -221,10 +220,9 @@ this.ui = (function() { // eslint-disable-line no-unused-vars this.element.style.margin = "0"; this.element.scrolling = "no"; this.updateElementSize(); - this.element.onload = watchFunction(() => { - this.element.onload = null; + this.element.addEventListener("load", watchFunction(() => { this.document = this.element.contentDocument; - assertIsBlankDocumentUrl(this.document.URL) + assertIsBlankDocument(this.document) this.document.documentElement.innerHTML = ` @@ -266,7 +264,7 @@ this.ui = (function() { // eslint-disable-line no-unused-vars overlay.querySelector(".full-page").addEventListener( "click", watchFunction(assertIsTrusted(standardOverlayCallbacks.onClickFullPage))); resolve(); - }); + }), {once: true}); document.body.appendChild(this.element); this.unhide(); } else { From ff2d8a47f3dca34df0e8dd4a304d5cad322954dc Mon Sep 17 00:00:00 2001 From: Jared Hirsch Date: Mon, 17 Jul 2017 16:24:11 -0700 Subject: [PATCH 3/3] Update version to 10.7.0 with changelog --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0ba83e70e..4476fa0bc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Version 10.7.0 + +* Fix icon path, so that starred icon is shown to new users ([#3136](https://github.com/mozilla-services/screenshots/issues/3136)) +* Address 10.6 review comments ([bugzilla bug 1381132](https://bugzil.la/1381132#c3)) + ## Version 10.6.0 * Iframe tests: validate iframe URLs, remove unneeded iframe onload handlers ([#3134](https://github.com/mozilla-services/screenshots/issues/3134)) diff --git a/package.json b/package.json index f8aa5a3322..0df7c48808 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "firefox-screenshots", "description": "An experiment in creating better shareable versions of content.", - "version": "10.6.0", + "version": "10.7.0", "author": "Mozilla (https://mozilla.org/)", "bugs": { "url": "https://github.com/mozilla-services/screenshots/issues"