Bug 1535661 - Fix CORS issues in Markup Panel r=pbro

One change is in `node.js::isScrollable()` so I decided to assign this to you for review. Feel free to re-assign as you feel appropriate if you don't have time.

### Try

https://treeherder.mozilla.org/#/jobs?repo=try&revision=2e2f20af3f902ea65436bcfd288b3e075d6508f8

Differential Revision: https://phabricator.services.mozilla.com/D23803

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Michael Ratcliffe 2019-03-18 09:22:50 +00:00
Родитель 1ee91a6323
Коммит cffcfc6b1c
2 изменённых файлов: 43 добавлений и 7 удалений

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

@ -265,7 +265,15 @@ class MainEventCollector {
}
getJQuery(node) {
if (Cu.isDeadWrapper(node)) {
return null;
}
const global = this.unwrap(node.ownerGlobal);
if (!global) {
return null;
}
const hasJQuery = global.jQuery && global.jQuery.fn && global.jQuery.fn.jquery;
if (hasJQuery) {
@ -390,14 +398,25 @@ class JQueryEventCollector extends MainEventCollector {
}
let eventsObj = null;
const data = jQuery._data || jQuery.data;
if (data) {
// jQuery 1.2+
eventsObj = data(node, "events");
try {
eventsObj = data(node, "events");
} catch (e) {
// We have no access to a JS object. This is probably due to a CORS
// violation. Using try / catch is the only way to avoid this error.
}
} else {
// JQuery 1.0 & 1.1
const entry = jQuery(node)[0];
let entry;
try {
entry = entry = jQuery(node)[0];
} catch (e) {
// We have no access to a JS object. This is probably due to a CORS
// violation. Using try / catch is the only way to avoid this error.
}
if (!entry || !entry.events) {
if (checkOnly) {
@ -474,7 +493,14 @@ class JQueryLiveEventCollector extends MainEventCollector {
// Any element matching the specified selector will trigger the live
// event.
const win = this.unwrap(node.ownerGlobal);
const events = data(win.document, "events");
let events = null;
try {
events = data(win.document, "events");
} catch (e) {
// We have no access to a JS object. This is probably due to a CORS
// violation. Using try / catch is the only way to avoid this error.
}
if (events) {
for (const [, eventHolder] of Object.entries(events)) {

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

@ -262,9 +262,15 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
}
// If it does, then check it also has scrollbars.
const walker = new DocumentWalker(this.rawNode, this.rawNode.ownerGlobal,
{ filter: scrollbarTreeWalkerFilter });
return !!walker.firstChild();
try {
const walker = new DocumentWalker(this.rawNode, this.rawNode.ownerGlobal,
{ filter: scrollbarTreeWalkerFilter });
return !!walker.firstChild();
} catch (e) {
// We have no access to a DOM object. This is probably due to a CORS
// violation. Using try / catch is the only way to avoid this error.
return false;
}
},
/**
@ -340,6 +346,10 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
// Get a reference to the custom element definition function.
const name = this.rawNode.localName;
if (!this.rawNode.ownerGlobal) {
return undefined;
}
const customElementsRegistry = this.rawNode.ownerGlobal.customElements;
const customElement = customElementsRegistry && customElementsRegistry.get(name);
if (!customElement) {