2014-01-05 23:27:25 +00:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
let gTestTab;
|
|
|
|
let gContentAPI;
|
|
|
|
let gContentWindow;
|
|
|
|
|
|
|
|
Components.utils.import("resource:///modules/UITour.jsm");
|
|
|
|
|
|
|
|
function test() {
|
2014-02-05 08:31:41 +00:00
|
|
|
UITourTest();
|
2014-01-05 23:27:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let tests = [
|
|
|
|
function test_info_icon(done) {
|
|
|
|
let popup = document.getElementById("UITourTooltip");
|
|
|
|
let title = document.getElementById("UITourTooltipTitle");
|
|
|
|
let desc = document.getElementById("UITourTooltipDescription");
|
|
|
|
let icon = document.getElementById("UITourTooltipIcon");
|
|
|
|
let buttons = document.getElementById("UITourTooltipButtons");
|
|
|
|
|
|
|
|
popup.addEventListener("popupshown", function onPopupShown() {
|
|
|
|
popup.removeEventListener("popupshown", onPopupShown);
|
|
|
|
|
|
|
|
is(title.textContent, "a title", "Popup should have correct title");
|
|
|
|
is(desc.textContent, "some text", "Popup should have correct description text");
|
|
|
|
|
|
|
|
let imageURL = getRootDirectory(gTestPath) + "image.png";
|
|
|
|
imageURL = imageURL.replace("chrome://mochitests/content/", "https://example.com/");
|
|
|
|
is(icon.src, imageURL, "Popup should have correct icon shown");
|
|
|
|
|
|
|
|
is(buttons.hasChildNodes(), false, "Popup should have no buttons");
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
gContentAPI.showInfo("urlbar", "a title", "some text", "image.png");
|
|
|
|
},
|
|
|
|
function test_info_buttons_1(done) {
|
|
|
|
let popup = document.getElementById("UITourTooltip");
|
|
|
|
let title = document.getElementById("UITourTooltipTitle");
|
|
|
|
let desc = document.getElementById("UITourTooltipDescription");
|
|
|
|
let icon = document.getElementById("UITourTooltipIcon");
|
|
|
|
|
|
|
|
popup.addEventListener("popupshown", function onPopupShown() {
|
|
|
|
popup.removeEventListener("popupshown", onPopupShown);
|
|
|
|
|
|
|
|
is(title.textContent, "another title", "Popup should have correct title");
|
|
|
|
is(desc.textContent, "moar text", "Popup should have correct description text");
|
|
|
|
|
|
|
|
let imageURL = getRootDirectory(gTestPath) + "image.png";
|
|
|
|
imageURL = imageURL.replace("chrome://mochitests/content/", "https://example.com/");
|
|
|
|
is(icon.src, imageURL, "Popup should have correct icon shown");
|
|
|
|
|
|
|
|
let buttons = document.getElementById("UITourTooltipButtons");
|
|
|
|
is(buttons.childElementCount, 2, "Popup should have two buttons");
|
|
|
|
|
|
|
|
is(buttons.childNodes[0].getAttribute("label"), "Button 1", "First button should have correct label");
|
|
|
|
is(buttons.childNodes[0].getAttribute("image"), "", "First button should have no image");
|
|
|
|
|
|
|
|
is(buttons.childNodes[1].getAttribute("label"), "Button 2", "Second button should have correct label");
|
|
|
|
is(buttons.childNodes[1].getAttribute("image"), imageURL, "Second button should have correct image");
|
|
|
|
|
|
|
|
popup.addEventListener("popuphidden", function onPopupHidden() {
|
|
|
|
popup.removeEventListener("popuphidden", onPopupHidden);
|
|
|
|
ok(true, "Popup should close automatically");
|
|
|
|
|
|
|
|
executeSoon(function() {
|
|
|
|
is(gContentWindow.callbackResult, "button1", "Correct callback should have been called");
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
EventUtils.synthesizeMouseAtCenter(buttons.childNodes[0], {}, window);
|
|
|
|
});
|
|
|
|
|
|
|
|
let buttons = gContentWindow.makeButtons();
|
|
|
|
gContentAPI.showInfo("urlbar", "another title", "moar text", "./image.png", buttons);
|
|
|
|
},
|
|
|
|
function test_info_buttons_2(done) {
|
|
|
|
let popup = document.getElementById("UITourTooltip");
|
|
|
|
let title = document.getElementById("UITourTooltipTitle");
|
|
|
|
let desc = document.getElementById("UITourTooltipDescription");
|
|
|
|
let icon = document.getElementById("UITourTooltipIcon");
|
|
|
|
|
|
|
|
popup.addEventListener("popupshown", function onPopupShown() {
|
|
|
|
popup.removeEventListener("popupshown", onPopupShown);
|
|
|
|
|
|
|
|
is(title.textContent, "another title", "Popup should have correct title");
|
|
|
|
is(desc.textContent, "moar text", "Popup should have correct description text");
|
|
|
|
|
|
|
|
let imageURL = getRootDirectory(gTestPath) + "image.png";
|
|
|
|
imageURL = imageURL.replace("chrome://mochitests/content/", "https://example.com/");
|
|
|
|
is(icon.src, imageURL, "Popup should have correct icon shown");
|
|
|
|
|
|
|
|
let buttons = document.getElementById("UITourTooltipButtons");
|
|
|
|
is(buttons.childElementCount, 2, "Popup should have two buttons");
|
|
|
|
|
|
|
|
is(buttons.childNodes[0].getAttribute("label"), "Button 1", "First button should have correct label");
|
|
|
|
is(buttons.childNodes[0].getAttribute("image"), "", "First button should have no image");
|
|
|
|
|
|
|
|
is(buttons.childNodes[1].getAttribute("label"), "Button 2", "Second button should have correct label");
|
|
|
|
is(buttons.childNodes[1].getAttribute("image"), imageURL, "Second button should have correct image");
|
|
|
|
|
|
|
|
popup.addEventListener("popuphidden", function onPopupHidden() {
|
|
|
|
popup.removeEventListener("popuphidden", onPopupHidden);
|
|
|
|
ok(true, "Popup should close automatically");
|
|
|
|
|
|
|
|
executeSoon(function() {
|
|
|
|
is(gContentWindow.callbackResult, "button2", "Correct callback should have been called");
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
EventUtils.synthesizeMouseAtCenter(buttons.childNodes[1], {}, window);
|
|
|
|
});
|
|
|
|
|
|
|
|
let buttons = gContentWindow.makeButtons();
|
|
|
|
gContentAPI.showInfo("urlbar", "another title", "moar text", "./image.png", buttons);
|
|
|
|
},
|
|
|
|
];
|