diff --git a/browser/base/content/newtab/newTab.css b/browser/base/content/newtab/newTab.css
index e30483c8f2e3..1bb154193649 100644
--- a/browser/base/content/newtab/newTab.css
+++ b/browser/base/content/newtab/newTab.css
@@ -207,3 +207,16 @@ input[type=button] {
background-color: #fff;
opacity: 0.01;
}
+
+/* PANEL */
+#sponsored-panel {
+ width: 330px;
+}
+
+#sponsored-panel description {
+ margin: 0;
+}
+
+#sponsored-panel .text-link {
+ margin: 12px 0 0;
+}
diff --git a/browser/base/content/newtab/newTab.xul b/browser/base/content/newtab/newTab.xul
index 9c21d25f4330..87e0c4beb8af 100644
--- a/browser/base/content/newtab/newTab.xul
+++ b/browser/base/content/newtab/newTab.xul
@@ -17,6 +17,14 @@
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&newtab.pageTitle;">
+
+
diff --git a/browser/base/content/newtab/page.js b/browser/base/content/newtab/page.js
index 41326ceb52ee..1eb126042b5e 100644
--- a/browser/base/content/newtab/page.js
+++ b/browser/base/content/newtab/page.js
@@ -23,6 +23,9 @@ let gPage = {
let button = document.getElementById("newtab-toggle");
button.addEventListener("click", this, false);
+ // Initialize sponsored panel
+ this._sponsoredPanel = document.getElementById("sponsored-panel");
+
// Check if the new tab feature is enabled.
let enabled = gAllPages.enabled;
if (enabled)
@@ -80,6 +83,21 @@ let gPage = {
}
},
+ /**
+ * Shows sponsored panel
+ */
+ showSponsoredPanel: function Page_showSponsoredPanel(aTarget) {
+ if (this._sponsoredPanel.state == "closed") {
+ let self = this;
+ this._sponsoredPanel.addEventListener("popuphidden", function onPopupHidden(aEvent) {
+ self._sponsoredPanel.removeEventListener("popuphidden", onPopupHidden, false);
+ aTarget.removeAttribute("panelShown");
+ });
+ }
+ aTarget.setAttribute("panelShown", "true");
+ this._sponsoredPanel.openPopup(aTarget);
+ },
+
/**
* Internally initializes the page. This runs only when/if the feature
* is/gets enabled.
diff --git a/browser/base/content/newtab/sites.js b/browser/base/content/newtab/sites.js
index 1a8f7ff4d8ee..5545b66ee56e 100644
--- a/browser/base/content/newtab/sites.js
+++ b/browser/base/content/newtab/sites.js
@@ -224,6 +224,8 @@ Site.prototype = {
aEvent.preventDefault();
if (aEvent.target.classList.contains("newtab-control-block"))
this.block();
+ else if (target.classList.contains("newtab-control-sponsored"))
+ gPage.showSponsoredPanel(target);
else if (this.isPinned())
this.unpin();
else
diff --git a/browser/base/content/test/newtab/browser.ini b/browser/base/content/test/newtab/browser.ini
index 01ec5ab570da..e91faaf259ea 100644
--- a/browser/base/content/test/newtab/browser.ini
+++ b/browser/base/content/test/newtab/browser.ini
@@ -21,6 +21,7 @@ skip-if = os == "mac" # Intermittent failures, bug 898317
[browser_newtab_focus.js]
[browser_newtab_perwindow_private_browsing.js]
[browser_newtab_reset.js]
+[browser_newtab_sponsored_icon_click.js]
[browser_newtab_tabsync.js]
[browser_newtab_undo.js]
[browser_newtab_unpin.js]
diff --git a/browser/base/content/test/newtab/browser_newtab_sponsored_icon_click.js b/browser/base/content/test/newtab/browser_newtab_sponsored_icon_click.js
new file mode 100644
index 000000000000..6253552c75c9
--- /dev/null
+++ b/browser/base/content/test/newtab/browser_newtab_sponsored_icon_click.js
@@ -0,0 +1,33 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function runTests() {
+ yield setLinks("0");
+ yield addNewTabPageTab();
+
+ let site = getCell(0).node.querySelector(".newtab-site");
+ site.setAttribute("type", "sponsored");
+
+ let sponsoredPanel = getContentDocument().getElementById("sponsored-panel");
+ is(sponsoredPanel.state, "closed", "Sponsored panel must be closed");
+
+ function continueOnceOn(event) {
+ sponsoredPanel.addEventListener(event, function listener() {
+ sponsoredPanel.removeEventListener(event, listener);
+ executeSoon(TestRunner.next);
+ });
+ }
+
+ // test sponsoredPanel appearing upon a click
+ continueOnceOn("popupshown");
+ let sponsoredButton = site.querySelector(".newtab-control-sponsored");
+ yield EventUtils.synthesizeMouseAtCenter(sponsoredButton, {}, getContentWindow());
+ is(sponsoredPanel.state, "open", "Sponsored panel opens on click");
+ ok(sponsoredButton.hasAttribute("panelShown"), "Sponsored button has panelShown attribute");
+
+ // test sponsoredPanel hiding
+ continueOnceOn("popuphidden");
+ yield sponsoredPanel.hidePopup();
+ is(sponsoredPanel.state, "closed", "Sponsored panel correctly closed/hidden");
+ ok(!sponsoredButton.hasAttribute("panelShown"), "Sponsored button does not have panelShown attribute");
+}
diff --git a/browser/locales/en-US/chrome/browser/newTab.dtd b/browser/locales/en-US/chrome/browser/newTab.dtd
index ce9e3e4b0b35..b85682d55129 100644
--- a/browser/locales/en-US/chrome/browser/newTab.dtd
+++ b/browser/locales/en-US/chrome/browser/newTab.dtd
@@ -8,3 +8,6 @@
+
+
+
diff --git a/browser/themes/linux/newtab/newTab.css b/browser/themes/linux/newtab/newTab.css
index 02ab6f2c8c84..4b8f55f4d1c9 100644
--- a/browser/themes/linux/newtab/newTab.css
+++ b/browser/themes/linux/newtab/newTab.css
@@ -183,3 +183,7 @@
.newtab-control-sponsored:hover {
background-position: -265px -1px;
}
+
+.newtab-control-sponsored[panelShown] {
+ background-position: -281px -1px;
+}
diff --git a/browser/themes/osx/newtab/newTab.css b/browser/themes/osx/newtab/newTab.css
index 2c29f2e516a2..b603839c4ffe 100644
--- a/browser/themes/osx/newtab/newTab.css
+++ b/browser/themes/osx/newtab/newTab.css
@@ -194,3 +194,7 @@
.newtab-control-sponsored:hover {
background-position: -265px -1px;
}
+
+.newtab-control-sponsored[panelShown] {
+ background-position: -281px -1px;
+}
diff --git a/browser/themes/windows/newtab/newTab.css b/browser/themes/windows/newtab/newTab.css
index 63498f6eb376..bfd15d712c79 100644
--- a/browser/themes/windows/newtab/newTab.css
+++ b/browser/themes/windows/newtab/newTab.css
@@ -186,3 +186,7 @@
.newtab-control-sponsored:hover {
background-position: -265px -1px;
}
+
+.newtab-control-sponsored[panelShown] {
+ background-position: -281px -1px;
+}