Bug 1121227 - Don't harcode the system app origin in touch-events.js r=ochameau

This commit is contained in:
Fabrice Desré 2015-01-14 13:32:52 -08:00
parent c815fdc069
commit 28774c3a81

View File

@ -11,6 +11,16 @@ let handlerCount = 0;
let orig_w3c_touch_events = Services.prefs.getIntPref('dom.w3c_touch_events.enabled');
let systemAppOrigin = (function() {
let systemOrigin = "_";
try {
systemOrigin = Services.io.newURI(
Services.prefs.getCharPref('b2g.system_manifest_url'), null, null)
.prePath;
} catch(e) {}
return systemOrigin;
})();
let trackedWindows = new WeakMap();
// =================== Touch ====================
@ -65,7 +75,10 @@ function TouchEventHandler (window) {
// a mix of mouse/touch events. So let's not cancel *all* mouse events
// if it is the current target.
let content = this.getContent(evt.target);
let isSystemWindow = content.location.toString().indexOf("system.gaiamobile.org") != -1;
if (!content) {
return;
}
let isSystemWindow = content.location.toString().startsWith(systemAppOrigin);
// App touchstart & touchend should also be dispatched on the system app
// to match on-device behavior.
@ -233,6 +246,9 @@ function TouchEventHandler (window) {
}
let document = target.ownerDocument;
let content = this.getContent(target);
if (!content) {
return null;
}
let touchEvent = document.createEvent('touchevent');
let point = document.createTouch(content, target, 0,
@ -250,7 +266,9 @@ function TouchEventHandler (window) {
return touchEvent;
},
getContent: function teh_getContent(target) {
let win = target.ownerDocument.defaultView;
let win = (target && target.ownerDocument)
? target.ownerDocument.defaultView
: null;
return win;
}
};