browser(firefox): assorted fixes for evaluation and remote objects (#510)
This commit is contained in:
parent
21510a5b06
commit
b4686f1eb9
|
|
@ -1 +1 @@
|
||||||
1013
|
1014
|
||||||
|
|
|
||||||
|
|
@ -1824,10 +1824,10 @@ index 0000000000000000000000000000000000000000..2508cce41565023b7fee9c7b85afe8ec
|
||||||
+
|
+
|
||||||
diff --git a/testing/juggler/content/PageAgent.js b/testing/juggler/content/PageAgent.js
|
diff --git a/testing/juggler/content/PageAgent.js b/testing/juggler/content/PageAgent.js
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..758871cc245ab5aa30ce54d58e87175f65401d50
|
index 0000000000000000000000000000000000000000..03c4c9717148169110f7e7d19306a76984ed4860
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/testing/juggler/content/PageAgent.js
|
+++ b/testing/juggler/content/PageAgent.js
|
||||||
@@ -0,0 +1,714 @@
|
@@ -0,0 +1,721 @@
|
||||||
+"use strict";
|
+"use strict";
|
||||||
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
+const Ci = Components.interfaces;
|
+const Ci = Components.interfaces;
|
||||||
|
|
@ -2051,13 +2051,20 @@ index 0000000000000000000000000000000000000000..758871cc245ab5aa30ce54d58e87175f
|
||||||
+ _filePickerShown(inputElement) {
|
+ _filePickerShown(inputElement) {
|
||||||
+ if (inputElement.ownerGlobal.docShell !== this._docShell)
|
+ if (inputElement.ownerGlobal.docShell !== this._docShell)
|
||||||
+ return;
|
+ return;
|
||||||
+ const frameData = Array.from(this._frameData.values()).find(data => inputElement.ownerDocument === data._frame.domWindow().document);
|
+ const frameData = this._findFrameForNode(inputElement);
|
||||||
+ this._session.emitEvent('Page.fileChooserOpened', {
|
+ this._session.emitEvent('Page.fileChooserOpened', {
|
||||||
+ executionContextId: frameData.mainContext.id(),
|
+ executionContextId: frameData.mainContext.id(),
|
||||||
+ element: frameData.mainContext.rawValueToRemoteObject(inputElement)
|
+ element: frameData.mainContext.rawValueToRemoteObject(inputElement)
|
||||||
+ });
|
+ });
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ _findFrameForNode(node) {
|
||||||
|
+ return Array.from(this._frameData.values()).find(data => {
|
||||||
|
+ const doc = data._frame.domWindow().document;
|
||||||
|
+ return node === doc || node.ownerDocument === doc;
|
||||||
|
+ });
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ _onDOMContentLoaded(event) {
|
+ _onDOMContentLoaded(event) {
|
||||||
+ const docShell = event.target.ownerGlobal.docShell;
|
+ const docShell = event.target.ownerGlobal.docShell;
|
||||||
+ const frame = this._frameTree.frameForDocShell(docShell);
|
+ const frame = this._frameTree.frameForDocShell(docShell);
|
||||||
|
|
@ -2265,15 +2272,15 @@ index 0000000000000000000000000000000000000000..758871cc245ab5aa30ce54d58e87175f
|
||||||
+ return {quads};
|
+ return {quads};
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ contentFrame({objectId, frameId}) {
|
+ describeNode({objectId, frameId}) {
|
||||||
+ const frame = this._frameTree.frame(frameId);
|
+ const frame = this._frameTree.frame(frameId);
|
||||||
+ if (!frame)
|
+ if (!frame)
|
||||||
+ throw new Error('Failed to find frame with id = ' + frameId);
|
+ throw new Error('Failed to find frame with id = ' + frameId);
|
||||||
+ const unsafeObject = this._frameData.get(frame).unsafeObject(objectId);
|
+ const unsafeObject = this._frameData.get(frame).unsafeObject(objectId);
|
||||||
+ if (!unsafeObject.contentWindow)
|
+ return {
|
||||||
+ return null;
|
+ contentFrameId: unsafeObject.contentWindow ? this._frameTree.frameForDocShell(unsafeObject.contentWindow.docShell).id() : undefined,
|
||||||
+ const contentFrame = this._frameTree.frameForDocShell(unsafeObject.contentWindow.docShell);
|
+ ownerFrameId: this._findFrameForNode(unsafeObject)._frame.id(),
|
||||||
+ return {frameId: contentFrame.id()};
|
+ };
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ async getBoundingBox({frameId, objectId}) {
|
+ async getBoundingBox({frameId, objectId}) {
|
||||||
|
|
@ -2544,10 +2551,10 @@ index 0000000000000000000000000000000000000000..758871cc245ab5aa30ce54d58e87175f
|
||||||
+
|
+
|
||||||
diff --git a/testing/juggler/content/RuntimeAgent.js b/testing/juggler/content/RuntimeAgent.js
|
diff --git a/testing/juggler/content/RuntimeAgent.js b/testing/juggler/content/RuntimeAgent.js
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..642b8bc1be7eaa6ad46ed38eee10dc58169d44ea
|
index 0000000000000000000000000000000000000000..262011d8fda346078a6cfcb7aae5dac357fb9b60
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/testing/juggler/content/RuntimeAgent.js
|
+++ b/testing/juggler/content/RuntimeAgent.js
|
||||||
@@ -0,0 +1,465 @@
|
@@ -0,0 +1,478 @@
|
||||||
+"use strict";
|
+"use strict";
|
||||||
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
+const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js');
|
+const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js');
|
||||||
|
|
@ -2813,7 +2820,18 @@ index 0000000000000000000000000000000000000000..642b8bc1be7eaa6ad46ed38eee10dc58
|
||||||
+ this._remoteObjects = new Map();
|
+ this._remoteObjects = new Map();
|
||||||
+ this._id = helper.generateId();
|
+ this._id = helper.generateId();
|
||||||
+ this._auxData = auxData;
|
+ this._auxData = auxData;
|
||||||
+ this._jsonStringifyObject = this._global.executeInGlobal('JSON.stringify.bind(JSON)').return;
|
+ this._jsonStringifyObject = this._global.executeInGlobal(`((stringify, dateProto, object) => {
|
||||||
|
+ const oldToJson = dateProto.toJSON;
|
||||||
|
+ dateProto.toJSON = undefined;
|
||||||
|
+ let hasSymbol = false;
|
||||||
|
+ const result = stringify(object, (key, value) => {
|
||||||
|
+ if (typeof value === 'symbol')
|
||||||
|
+ hasSymbol = true;
|
||||||
|
+ return value;
|
||||||
|
+ });
|
||||||
|
+ dateProto.toJSON = oldToJson;
|
||||||
|
+ return hasSymbol ? undefined : result;
|
||||||
|
+ }).bind(null, JSON.stringify.bind(JSON), Date.prototype)`).return;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ id() {
|
+ id() {
|
||||||
|
|
@ -2949,6 +2967,8 @@ index 0000000000000000000000000000000000000000..642b8bc1be7eaa6ad46ed38eee10dc58
|
||||||
+ _toDebugger(obj) {
|
+ _toDebugger(obj) {
|
||||||
+ if (typeof obj !== 'object')
|
+ if (typeof obj !== 'object')
|
||||||
+ return obj;
|
+ return obj;
|
||||||
|
+ if (obj === null)
|
||||||
|
+ return obj;
|
||||||
+ const properties = {};
|
+ const properties = {};
|
||||||
+ for (let [key, value] of Object.entries(obj)) {
|
+ for (let [key, value] of Object.entries(obj)) {
|
||||||
+ properties[key] = {
|
+ properties[key] = {
|
||||||
|
|
@ -2967,7 +2987,7 @@ index 0000000000000000000000000000000000000000..642b8bc1be7eaa6ad46ed38eee10dc58
|
||||||
+ const result = this._global.executeInGlobalWithBindings('stringify(e)', {e: obj, stringify: this._jsonStringifyObject});
|
+ const result = this._global.executeInGlobalWithBindings('stringify(e)', {e: obj, stringify: this._jsonStringifyObject});
|
||||||
+ if (result.throw)
|
+ if (result.throw)
|
||||||
+ throw new Error('Object is not serializable');
|
+ throw new Error('Object is not serializable');
|
||||||
+ return JSON.parse(result.return);
|
+ return result.return === undefined ? undefined : JSON.parse(result.return);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ disposeObject(objectId) {
|
+ disposeObject(objectId) {
|
||||||
|
|
@ -3793,10 +3813,10 @@ index 0000000000000000000000000000000000000000..f5e7e919594b3778fd3046bf69d34878
|
||||||
+this.NetworkHandler = NetworkHandler;
|
+this.NetworkHandler = NetworkHandler;
|
||||||
diff --git a/testing/juggler/protocol/PageHandler.js b/testing/juggler/protocol/PageHandler.js
|
diff --git a/testing/juggler/protocol/PageHandler.js b/testing/juggler/protocol/PageHandler.js
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..db0648f6bee8035c7750cd810281ad0286540576
|
index 0000000000000000000000000000000000000000..bf59b2afa8692d02fd0ce664eec2e9827a8209d2
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/testing/juggler/protocol/PageHandler.js
|
+++ b/testing/juggler/protocol/PageHandler.js
|
||||||
@@ -0,0 +1,285 @@
|
@@ -0,0 +1,281 @@
|
||||||
+"use strict";
|
+"use strict";
|
||||||
+
|
+
|
||||||
+const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js');
|
+const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js');
|
||||||
|
|
@ -3974,12 +3994,8 @@ index 0000000000000000000000000000000000000000..db0648f6bee8035c7750cd810281ad02
|
||||||
+ return await this._contentSession.send('Page.reload', options);
|
+ return await this._contentSession.send('Page.reload', options);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ async describeNode(options) {
|
||||||
+ * @param {{frameId: String, objectId: String}} options
|
+ return await this._contentSession.send('Page.describeNode', options);
|
||||||
+ * @return {!Promise<*>}
|
|
||||||
+ */
|
|
||||||
+ async contentFrame(options) {
|
|
||||||
+ return await this._contentSession.send('Page.contentFrame', options);
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ async addScriptToEvaluateOnNewDocument(options) {
|
+ async addScriptToEvaluateOnNewDocument(options) {
|
||||||
|
|
@ -4233,10 +4249,10 @@ index 0000000000000000000000000000000000000000..78b6601b91d0b7fcda61114e6846aa07
|
||||||
+this.EXPORTED_SYMBOLS = ['t', 'checkScheme'];
|
+this.EXPORTED_SYMBOLS = ['t', 'checkScheme'];
|
||||||
diff --git a/testing/juggler/protocol/Protocol.js b/testing/juggler/protocol/Protocol.js
|
diff --git a/testing/juggler/protocol/Protocol.js b/testing/juggler/protocol/Protocol.js
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0344e2c71a86aff1ab602d9a90c8f2a0817cb66b
|
index 0000000000000000000000000000000000000000..75b5276d085bd4217389cd05099895ebec2438b6
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/testing/juggler/protocol/Protocol.js
|
+++ b/testing/juggler/protocol/Protocol.js
|
||||||
@@ -0,0 +1,711 @@
|
@@ -0,0 +1,712 @@
|
||||||
+const {t, checkScheme} = ChromeUtils.import('chrome://juggler/content/protocol/PrimitiveTypes.js');
|
+const {t, checkScheme} = ChromeUtils.import('chrome://juggler/content/protocol/PrimitiveTypes.js');
|
||||||
+
|
+
|
||||||
+// Protocol-specific types.
|
+// Protocol-specific types.
|
||||||
|
|
@ -4776,13 +4792,14 @@ index 0000000000000000000000000000000000000000..0344e2c71a86aff1ab602d9a90c8f2a0
|
||||||
+ enabled: t.Boolean,
|
+ enabled: t.Boolean,
|
||||||
+ },
|
+ },
|
||||||
+ },
|
+ },
|
||||||
+ 'contentFrame': {
|
+ 'describeNode': {
|
||||||
+ params: {
|
+ params: {
|
||||||
+ frameId: t.String,
|
+ frameId: t.String,
|
||||||
+ objectId: t.String,
|
+ objectId: t.String,
|
||||||
+ },
|
+ },
|
||||||
+ returns: {
|
+ returns: {
|
||||||
+ frameId: t.Nullable(t.String),
|
+ contentFrameId: t.Optional(t.String),
|
||||||
|
+ ownerFrameId: t.Optional(t.String),
|
||||||
+ },
|
+ },
|
||||||
+ },
|
+ },
|
||||||
+ 'addScriptToEvaluateOnNewDocument': {
|
+ 'addScriptToEvaluateOnNewDocument': {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue