Skip to content

Commit

Permalink
Backed out changeset 3af67a62be1b (bug 1367077) for failing mochitest…
Browse files Browse the repository at this point in the history
…-chrome's test_hidden_select_option.html and test_select_disabled.html on Android. r=backout

UltraBlame original commit: 763af7d6686da5cabb27188dafd70d9ef07ce9f0
  • Loading branch information
marco-c committed Oct 2, 2019
1 parent 2c5002c commit 17a49e0
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 189 deletions.
55 changes: 41 additions & 14 deletions mobile/android/components/BrowserCLH.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@



const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;

Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");

XPCOMUtils.defineLazyModuleGetters(this, {
AppConstants: "resource://gre/modules/AppConstants.jsm",
GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.jsm",
Services: "resource://gre/modules/Services.jsm",
});
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");

var Strings = {};

Expand Down Expand Up @@ -40,20 +40,47 @@ BrowserCLH.prototype = {
protocolHandler.setSubstitution("android", Services.io.newURI(url));
},

addObserverScripts: function(aScripts) {
aScripts.forEach(item => {
let {name, topics, script} = item;
XPCOMUtils.defineLazyGetter(this, name, _ => {
let sandbox = {};
if (script.endsWith(".jsm")) {
Cu.import(script, sandbox);
} else {
Services.scriptloader.loadSubScript(script, sandbox);
}
return sandbox[name];
});
let observer = (subject, topic, data) => {
Services.obs.removeObserver(observer, topic);
if (!item.once) {
Services.obs.addObserver(this[name], topic);
}
this[name].observe(subject, topic, data);
};
topics.forEach(topic => {
Services.obs.addObserver(observer, topic);
});
});
},

observe: function(subject, topic, data) {
switch (topic) {
case "app-startup": {
case "app-startup":
this.setResourceSubstitutions();

GeckoViewUtils.addLazyGetter(this, "DownloadNotifications", {
module: "resource://gre/modules/DownloadNotifications.jsm",
observers: ["chrome-document-loaded"],
let observerScripts = [{
name: "DownloadNotifications",
script: "resource://gre/modules/DownloadNotifications.jsm",
topics: ["chrome-document-interactive"],
once: true,
});
}];
if (AppConstants.MOZ_WEBRTC) {
GeckoViewUtils.addLazyGetter(this, "WebrtcUI", {
observerScripts.push({
name: "WebrtcUI",
script: "chrome://browser/content/WebrtcUI.js",
observers: [
topics: [
"getUserMedia:ask-device-permission",
"getUserMedia:request",
"PeerConnection:request",
Expand All @@ -63,8 +90,8 @@ BrowserCLH.prototype = {
],
});
}
this.addObserverScripts(observerScripts);
break;
}
}
},

Expand Down
85 changes: 74 additions & 11 deletions mobile/android/components/geckoview/GeckoViewStartup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

Cu.import("resource://gre/modules/XPCOMUtils.jsm");

XPCOMUtils.defineLazyModuleGetters(this, {
GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.jsm",
Services: "resource://gre/modules/Services.jsm",
});
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");

function GeckoViewStartup() {
}
Expand All @@ -19,6 +17,59 @@ GeckoViewStartup.prototype = {

QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),

addLazyGetter: function({name, script, service, module,
observers, ppmm, mm, init, once}) {
if (script) {
XPCOMUtils.defineLazyScriptGetter(this, name, script);
} else if (module) {
XPCOMUtils.defineLazyGetter(this, name, _ => {
let sandbox = {};
Cu.import(module, sandbox);
if (init) {
init.call(this, sandbox[name]);
}
return sandbox[name];
});
} else if (service) {
XPCOMUtils.defineLazyGetter(this, name, _ =>
Cc[service].getService(Ci.nsISupports).wrappedJSObject);
}

if (observers) {
let observer = (subject, topic, data) => {
Services.obs.removeObserver(observer, topic);
if (!once) {
Services.obs.addObserver(this[name], topic);
}
this[name].observe(subject, topic, data);
};
observers.forEach(topic => Services.obs.addObserver(observer, topic));
}

if (ppmm || mm) {
let target = ppmm ? Services.ppmm : Services.mm;
let listener = msg => {
target.removeMessageListener(msg.name, listener);
if (!once) {
target.addMessageListener(msg.name, this[name]);
}
this[name].receiveMessage(msg);
};
(ppmm || mm).forEach(msg => target.addMessageListener(msg, listener));
}
},

addLazyEventListener: function({name, target, events, options}) {
let listener = event => {
if (!options || !options.once) {
target.removeEventListener(event.type, listener, options);
target.addEventListener(event.type, this[name], options);
}
this[name].handleEvent(event);
};
events.forEach(event => target.addEventListener(event, listener, options));
},


observe: function(aSubject, aTopic, aData) {
switch (aTopic) {
Expand All @@ -27,7 +78,8 @@ GeckoViewStartup.prototype = {
Services.obs.addObserver(this, "chrome-document-global-created");
Services.obs.addObserver(this, "content-document-global-created");

GeckoViewUtils.addLazyGetter(this, "GeckoViewPermission", {
this.addLazyGetter({
name: "GeckoViewPermission",
service: "@mozilla.org/content-permission/prompt;1",
observers: [
"getUserMedia:ask-device-permission",
Expand All @@ -38,7 +90,8 @@ GeckoViewStartup.prototype = {

if (Services.appinfo.processType != Services.appinfo.PROCESS_TYPE_DEFAULT) {

GeckoViewUtils.addLazyGetter(this, "GeckoViewPrompt", {
this.addLazyGetter({
name: "GeckoViewPrompt",
service: "@mozilla.org/prompter;1",
});
}
Expand All @@ -48,7 +101,8 @@ GeckoViewStartup.prototype = {
case "profile-after-change": {


GeckoViewUtils.addLazyGetter(this, "ContentPrefServiceParent", {
this.addLazyGetter({
name: "ContentPrefServiceParent",
module: "resource://gre/modules/ContentPrefServiceParent.jsm",
init: cpsp => cpsp.alwaysInit(),
ppmm: [
Expand All @@ -58,7 +112,8 @@ GeckoViewStartup.prototype = {
],
});

GeckoViewUtils.addLazyGetter(this, "GeckoViewPrompt", {
this.addLazyGetter({
name: "GeckoViewPrompt",
service: "@mozilla.org/prompter;1",
mm: [
"GeckoView:Prompt",
Expand All @@ -69,14 +124,22 @@ GeckoViewStartup.prototype = {

case "chrome-document-global-created":
case "content-document-global-created": {
let win = GeckoViewUtils.getChromeWindow(aSubject);
let win = aSubject.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell).QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
if (win !== aSubject) {

return;
}

GeckoViewUtils.addLazyEventListener(win, ["click", "contextmenu"], {
handler: _ => this.GeckoViewPrompt,
this.addLazyEventListener({
name: "GeckoViewPrompt",
target: win,
events: [
"click",
"contextmenu",
],
options: {
capture: false,
mozSystemGroup: true,
Expand Down
2 changes: 1 addition & 1 deletion mobile/android/modules/DownloadNotifications.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var DownloadNotifications = {
_notificationKey: "downloads",

observe: function(subject, topic, data) {
if (topic === "chrome-document-loaded") {
if (topic === "chrome-document-interactive") {
this.init();
}
},
Expand Down
162 changes: 0 additions & 162 deletions mobile/android/modules/geckoview/GeckoViewUtils.jsm

This file was deleted.

Loading

0 comments on commit 17a49e0

Please sign in to comment.