Backed out changeset 32c21104e02c (bug 1164510) for causing frequent browser_UITour_loop.js failures.

This commit is contained in:
Ryan VanderMeulen 2015-06-11 15:14:56 -04:00
Родитель 0b43d41761
Коммит fdb32e04fb
19 изменённых файлов: 77 добавлений и 121 удалений

Просмотреть файл

@ -522,38 +522,38 @@ let LoopUI;
* has been fetched.
*/
getFavicon: function(callback) {
let pageURI = gBrowser.selectedTab.linkedBrowser.currentURI.spec;
// If the tab pages url starts with http(s), fetch icon.
if (!/^https?:/.test(pageURI)) {
callback();
let favicon = gBrowser.getIcon(gBrowser.selectedTab);
// If the tab image's url starts with http(s), fetch icon from favicon
// service via the moz-anno protocol.
if (/^https?:/.test(favicon)) {
let faviconURI = makeURI(favicon);
favicon = this.favIconService.getFaviconLinkForIcon(faviconURI).spec;
}
if (!favicon) {
callback(new Error("No favicon found"));
return;
}
favicon = this.PlacesUtils.getImageURLForResolution(window, favicon);
this.PlacesUtils.promiseFaviconLinkUrl(pageURI).then(uri => {
uri = this.PlacesUtils.getImageURLForResolution(window, uri.spec);
// We XHR the favicon to get a File object, which we can pass to the FileReader
// object. The FileReader turns the File object into a data-uri.
let xhr = new XMLHttpRequest();
xhr.open("get", favicon, true);
xhr.responseType = "blob";
xhr.overrideMimeType("image/x-icon");
xhr.onload = () => {
if (xhr.status != 200) {
callback(new Error("Invalid status code received for favicon XHR: " + xhr.status));
return;
}
// We XHR the favicon to get a File object, which we can pass to the FileReader
// object. The FileReader turns the File object into a data-uri.
let xhr = new XMLHttpRequest();
xhr.open("get", uri, true);
xhr.responseType = "blob";
xhr.overrideMimeType("image/x-icon");
xhr.onload = () => {
if (xhr.status != 200) {
callback(new Error("Invalid status code received for favicon XHR: " + xhr.status));
return;
}
let reader = new FileReader();
reader.onload = reader.onload = () => callback(null, reader.result);
reader.onerror = callback;
reader.readAsDataURL(xhr.response);
};
xhr.onerror = callback;
xhr.send();
}).catch(err => {
callback(err || new Error("No favicon found"));
});
let reader = new FileReader();
reader.onload = () => callback(null, reader.result);
reader.onerror = callback;
reader.readAsDataURL(xhr.response);
};
xhr.onerror = callback;
xhr.send();
}
};
})();
@ -563,3 +563,5 @@ XPCOMUtils.defineLazyModuleGetter(LoopUI, "LoopRooms", "resource:///modules/loop
XPCOMUtils.defineLazyModuleGetter(LoopUI, "MozLoopService", "resource:///modules/loop/MozLoopService.jsm");
XPCOMUtils.defineLazyModuleGetter(LoopUI, "PanelFrame", "resource:///modules/PanelFrame.jsm");
XPCOMUtils.defineLazyModuleGetter(LoopUI, "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyServiceGetter(LoopUI, "favIconService",
"@mozilla.org/browser/favicon-service;1", "nsIFaviconService");

Просмотреть файл

@ -269,6 +269,10 @@ html[dir="rtl"] .new-room-view > .context > .context-content > .context-preview
float: left;
}
.new-room-view > .context > .context-content > .context-preview[src=""] {
display: none;
}
.new-room-view > .context > .context-content > .context-description {
flex: 0 1 auto;
display: block;

Просмотреть файл

@ -29,7 +29,7 @@ loop.conversationViews = (function(mozL10n) {
if (!contact.email || contact.email.length === 0) {
return { value: "" };
}
return contact.email.find(function find(e) { return e.pref; }) || contact.email[0];
return contact.email.find(e => e.pref) || contact.email[0];
}
function _getContactDisplayName(contact) {

Просмотреть файл

@ -29,7 +29,7 @@ loop.conversationViews = (function(mozL10n) {
if (!contact.email || contact.email.length === 0) {
return { value: "" };
}
return contact.email.find(function find(e) { return e.pref; }) || contact.email[0];
return contact.email.find(e => e.pref) || contact.email[0];
}
function _getContactDisplayName(contact) {

Просмотреть файл

@ -500,8 +500,9 @@ loop.panel = (function(_, mozL10n) {
return (
React.createElement("div", {className: "room-entry-context-item"},
React.createElement("a", {href: roomUrl.location, title: roomUrl.description, onClick: this.handleClick},
React.createElement("img", {src: roomUrl.thumbnail || "loop/shared/img/icons-16x16.svg#globe"})
React.createElement("a", {href: roomUrl.location, onClick: this.handleClick},
React.createElement("img", {title: roomUrl.description,
src: roomUrl.thumbnail})
)
)
);
@ -765,7 +766,6 @@ loop.panel = (function(_, mozL10n) {
hide: !hostname ||
!this.props.mozLoop.getLoopPref("contextInConversations.enabled")
});
var thumbnail = this.state.previewImage || "loop/shared/img/icons-16x16.svg#globe";
return (
React.createElement("div", {className: "new-room-view"},
@ -773,7 +773,7 @@ loop.panel = (function(_, mozL10n) {
React.createElement(Checkbox, {label: mozL10n.get("context_inroom_label"),
onChange: this.onCheckboxChange}),
React.createElement("div", {className: "context-content"},
React.createElement("img", {className: "context-preview", src: thumbnail}),
React.createElement("img", {className: "context-preview", src: this.state.previewImage}),
React.createElement("span", {className: "context-description"},
this.state.description,
React.createElement("span", {className: "context-url"}, hostname)

Просмотреть файл

@ -500,8 +500,9 @@ loop.panel = (function(_, mozL10n) {
return (
<div className="room-entry-context-item">
<a href={roomUrl.location} title={roomUrl.description} onClick={this.handleClick}>
<img src={roomUrl.thumbnail || "loop/shared/img/icons-16x16.svg#globe"} />
<a href={roomUrl.location} onClick={this.handleClick}>
<img title={roomUrl.description}
src={roomUrl.thumbnail} />
</a>
</div>
);
@ -765,7 +766,6 @@ loop.panel = (function(_, mozL10n) {
hide: !hostname ||
!this.props.mozLoop.getLoopPref("contextInConversations.enabled")
});
var thumbnail = this.state.previewImage || "loop/shared/img/icons-16x16.svg#globe";
return (
<div className="new-room-view">
@ -773,7 +773,7 @@ loop.panel = (function(_, mozL10n) {
<Checkbox label={mozL10n.get("context_inroom_label")}
onChange={this.onCheckboxChange} />
<div className="context-content">
<img className="context-preview" src={thumbnail} />
<img className="context-preview" src={this.state.previewImage}/>
<span className="context-description">
{this.state.description}
<span className="context-url">{hostname}</span>

Просмотреть файл

@ -480,7 +480,7 @@ loop.roomViews = (function(mozL10n) {
}
var url = this._getURL();
var thumbnail = url && url.thumbnail || "loop/shared/img/icons-16x16.svg#globe";
var thumbnail = url && url.thumbnail || "";
var urlDescription = url && url.description || "";
var location = url && url.location || "";
var locationData = null;

Просмотреть файл

@ -480,7 +480,7 @@ loop.roomViews = (function(mozL10n) {
}
var url = this._getURL();
var thumbnail = url && url.thumbnail || "loop/shared/img/icons-16x16.svg#globe";
var thumbnail = url && url.thumbnail || "";
var urlDescription = url && url.description || "";
var location = url && url.location || "";
var locationData = null;
@ -553,7 +553,7 @@ loop.roomViews = (function(mozL10n) {
<div className="room-context-label">{mozL10n.get("context_inroom_label")}</div>
<div className="room-context-content"
onClick={this.handleContextClick}>
<img className="room-context-thumbnail" src={thumbnail} />
<img className="room-context-thumbnail" src={thumbnail}/>
<div className="room-context-description"
title={urlDescription}>
{this._truncate(urlDescription)}

Просмотреть файл

@ -969,6 +969,10 @@ body[platform="win"] .share-service-dropdown.overflow > .dropdown-menu-item {
flex: 0 1 auto;
}
.room-context-thumbnail[src=""] {
display: none;
}
.room-context > .error-display-area.error {
display: block;
background-color: rgba(215,67,69,.8);
@ -1207,8 +1211,9 @@ html[dir="rtl"] .room-context-btn-edit {
.standalone-context-url > img {
margin: 1em auto;
width: 16px;
height: 16px;
max-width: 50%;
/* allows 20% for the description wrapper plus the margins */
max-height: calc(80% - 2em);
}
.standalone-context-url-description-wrapper {

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

До

Ширина:  |  Высота:  |  Размер: 73 KiB

После

Ширина:  |  Высота:  |  Размер: 13 KiB

Просмотреть файл

@ -262,7 +262,7 @@ loop.standaloneRoomViews = (function(mozL10n) {
return (
React.createElement("div", {className: classes},
React.createElement("img", {src: this.props.roomContextUrl.thumbnail || "shared/img/icons-16x16.svg#globe"}),
React.createElement("img", {src: this.props.roomContextUrl.thumbnail}),
React.createElement("div", {className: "standalone-context-url-description-wrapper"},
this.props.roomContextUrl.description,
React.createElement("br", null), React.createElement("a", {href: locationInfo.location,

Просмотреть файл

@ -262,7 +262,7 @@ loop.standaloneRoomViews = (function(mozL10n) {
return (
<div className={classes}>
<img src={this.props.roomContextUrl.thumbnail || "shared/img/icons-16x16.svg#globe"} />
<img src={this.props.roomContextUrl.thumbnail} />
<div className="standalone-context-url-description-wrapper">
{this.props.roomContextUrl.description}
<br /><a href={locationInfo.location}

Просмотреть файл

@ -850,24 +850,6 @@ describe("loop.panel", function() {
expect(contextContent).to.not.equal(null);
});
it("should show a default favicon when none is available", function() {
fakeMozLoop.getSelectedTabMetadata = function (callback) {
callback({
url: "https://www.example.com",
description: "fake description",
previews: [""]
});
};
var view = createTestComponent();
// Simulate being visible
view.onDocumentVisible();
var previewImage = view.getDOMNode().querySelector(".context-preview");
expect(previewImage.src).to.match(/loop\/shared\/img\/icons-16x16.svg#globe$/);
});
it("should not show context information when a URL is unavailable", function() {
fakeMozLoop.getSelectedTabMetadata = function (callback) {
callback({

Просмотреть файл

@ -305,19 +305,6 @@ describe("loop.roomViews", function () {
expect(view.getDOMNode().querySelector(".room-context-url").textContent)
.eql("hostname");
});
it("should show a default favicon when none is available", function() {
fakeContextURL.thumbnail = null;
view = mountTestComponent({
showContext: true,
roomData: {
roomContextUrls: [fakeContextURL]
}
});
expect(view.getDOMNode().querySelector(".room-context-thumbnail").src)
.to.match(/loop\/shared\/img\/icons-16x16.svg#globe$/);
});
});
});

Просмотреть файл

@ -28,22 +28,10 @@ add_task(function* test_mozLoop_getSelectedTabMetadata() {
metadata = yield promiseGetMetadata();
Assert.strictEqual(metadata.url, null, "URL should be empty for about:home");
Assert.strictEqual(metadata.favicon, null, "Favicon should be empty for about:home");
Assert.ok(metadata.favicon.startsWith("data:image/x-icon;base64,"),
"Favicon should be set for about:home");
Assert.ok(metadata.title, "Title should be set for about:home");
Assert.deepEqual(metadata.previews, [], "No previews available for about:home");
gBrowser.removeTab(tab);
});
add_task(function* test_mozLoop_getSelectedTabMetadata_defaultIcon() {
let tab = gBrowser.selectedTab = gBrowser.addTab();
yield promiseTabLoadEvent(tab, "http://example.com/");
let metadata = yield promiseGetMetadata();
Assert.strictEqual(metadata.url, "http://example.com/", "URL should match");
Assert.strictEqual(metadata.favicon, null, "Favicon should be empty");
Assert.ok(metadata.title, "Title should be set");
Assert.deepEqual(metadata.previews, [], "No previews available");
gBrowser.removeTab(tab);
});

Просмотреть файл

@ -149,20 +149,6 @@ describe("loop.standaloneRoomViews", function() {
linkInfo: "Shared URL"
}));
});
it("should display the default favicon when no thumbnail is available", function() {
var view = mountTestComponent({
roomName: "Mike's room",
roomContextUrls: [{
description: "Mark's super page",
location: "http://invalid.com",
thumbnail: ""
}]
});
expect(view.getDOMNode().querySelector(".standalone-context-url > img").src)
.to.match(/shared\/img\/icons-16x16.svg#globe$/);
});
});
describe("StandaloneRoomHeader", function() {

Просмотреть файл

@ -148,6 +148,10 @@ body {
.svg-icon {
display: inline-block;
width: 16px;
height: 16px;
margin-left: .5rem;
border: 0;
background-repeat: no-repeat;
background-size: 16px 16px;
background-position: center;
}

Просмотреть файл

@ -300,12 +300,13 @@
var SVGIcon = React.createClass({displayName: "SVGIcon",
render: function() {
var sizeUnit = this.props.size.split("x");
var sizeUnit = this.props.size.split("x")[0] + "px";
return (
React.createElement("img", {className: "svg-icon",
src: "../content/shared/img/icons-" + this.props.size + ".svg#" + this.props.shapeId,
width: sizeUnit[0],
height: sizeUnit[1]})
React.createElement("span", {className: "svg-icon", style: {
"backgroundImage": "url(../content/shared/img/icons-" + this.props.size +
".svg#" + this.props.shapeId + ")",
"backgroundSize": sizeUnit + " " + sizeUnit
}})
);
}
});
@ -327,7 +328,7 @@
],
"16x16": ["add", "add-hover", "add-active", "audio", "audio-hover", "audio-active",
"block", "block-red", "block-hover", "block-active", "contacts", "contacts-hover",
"contacts-active", "copy", "checkmark", "delete", "globe", "google", "google-hover",
"contacts-active", "copy", "checkmark", "delete", "google", "google-hover",
"google-active", "history", "history-hover", "history-active", "leave",
"precall", "precall-hover", "precall-active", "screen-white", "screenmute-white",
"settings", "settings-hover", "settings-active", "share-darkgrey", "tag",

Просмотреть файл

@ -300,12 +300,13 @@
var SVGIcon = React.createClass({
render: function() {
var sizeUnit = this.props.size.split("x");
var sizeUnit = this.props.size.split("x")[0] + "px";
return (
<img className="svg-icon"
src={"../content/shared/img/icons-" + this.props.size + ".svg#" + this.props.shapeId}
width={sizeUnit[0]}
height={sizeUnit[1]} />
<span className="svg-icon" style={{
"backgroundImage": "url(../content/shared/img/icons-" + this.props.size +
".svg#" + this.props.shapeId + ")",
"backgroundSize": sizeUnit + " " + sizeUnit
}} />
);
}
});
@ -327,7 +328,7 @@
],
"16x16": ["add", "add-hover", "add-active", "audio", "audio-hover", "audio-active",
"block", "block-red", "block-hover", "block-active", "contacts", "contacts-hover",
"contacts-active", "copy", "checkmark", "delete", "globe", "google", "google-hover",
"contacts-active", "copy", "checkmark", "delete", "google", "google-hover",
"google-active", "history", "history-hover", "history-active", "leave",
"precall", "precall-hover", "precall-active", "screen-white", "screenmute-white",
"settings", "settings-hover", "settings-active", "share-darkgrey", "tag",