summaryrefslogtreecommitdiffstats
path: root/devtools/shared/commands/resource/transformers
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--devtools/shared/commands/resource/transformers/console-messages.js23
-rw-r--r--devtools/shared/commands/resource/transformers/error-messages.js31
-rw-r--r--devtools/shared/commands/resource/transformers/moz.build16
-rw-r--r--devtools/shared/commands/resource/transformers/network-events.js16
-rw-r--r--devtools/shared/commands/resource/transformers/storage-cache.js22
-rw-r--r--devtools/shared/commands/resource/transformers/storage-cookie.js26
-rw-r--r--devtools/shared/commands/resource/transformers/storage-extension.js26
-rw-r--r--devtools/shared/commands/resource/transformers/storage-indexed-db.js26
-rw-r--r--devtools/shared/commands/resource/transformers/storage-local-storage.js22
-rw-r--r--devtools/shared/commands/resource/transformers/storage-session-storage.js22
-rw-r--r--devtools/shared/commands/resource/transformers/thread-states.js32
11 files changed, 262 insertions, 0 deletions
diff --git a/devtools/shared/commands/resource/transformers/console-messages.js b/devtools/shared/commands/resource/transformers/console-messages.js
new file mode 100644
index 0000000000..9c8ca51f04
--- /dev/null
+++ b/devtools/shared/commands/resource/transformers/console-messages.js
@@ -0,0 +1,23 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+// eslint-disable-next-line mozilla/reject-some-requires
+loader.lazyRequireGetter(
+ this,
+ "getAdHocFrontOrPrimitiveGrip",
+ "resource://devtools/client/fronts/object.js",
+ true
+);
+
+module.exports = function ({ resource, targetFront }) {
+ if (Array.isArray(resource.message.arguments)) {
+ // We might need to create fronts for each of the message arguments.
+ resource.message.arguments = resource.message.arguments.map(arg =>
+ getAdHocFrontOrPrimitiveGrip(arg, targetFront)
+ );
+ }
+ return resource;
+};
diff --git a/devtools/shared/commands/resource/transformers/error-messages.js b/devtools/shared/commands/resource/transformers/error-messages.js
new file mode 100644
index 0000000000..2b71f5b7ca
--- /dev/null
+++ b/devtools/shared/commands/resource/transformers/error-messages.js
@@ -0,0 +1,31 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+// eslint-disable-next-line mozilla/reject-some-requires
+loader.lazyRequireGetter(
+ this,
+ "getAdHocFrontOrPrimitiveGrip",
+ "resource://devtools/client/fronts/object.js",
+ true
+);
+
+module.exports = function ({ resource, targetFront }) {
+ if (resource?.pageError?.errorMessage) {
+ resource.pageError.errorMessage = getAdHocFrontOrPrimitiveGrip(
+ resource.pageError.errorMessage,
+ targetFront
+ );
+ }
+
+ if (resource?.pageError?.exception) {
+ resource.pageError.exception = getAdHocFrontOrPrimitiveGrip(
+ resource.pageError.exception,
+ targetFront
+ );
+ }
+
+ return resource;
+};
diff --git a/devtools/shared/commands/resource/transformers/moz.build b/devtools/shared/commands/resource/transformers/moz.build
new file mode 100644
index 0000000000..5b0b94853a
--- /dev/null
+++ b/devtools/shared/commands/resource/transformers/moz.build
@@ -0,0 +1,16 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+DevToolsModules(
+ "console-messages.js",
+ "error-messages.js",
+ "network-events.js",
+ "storage-cache.js",
+ "storage-cookie.js",
+ "storage-extension.js",
+ "storage-indexed-db.js",
+ "storage-local-storage.js",
+ "storage-session-storage.js",
+ "thread-states.js",
+)
diff --git a/devtools/shared/commands/resource/transformers/network-events.js b/devtools/shared/commands/resource/transformers/network-events.js
new file mode 100644
index 0000000000..d7f757d706
--- /dev/null
+++ b/devtools/shared/commands/resource/transformers/network-events.js
@@ -0,0 +1,16 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const {
+ getUrlDetails,
+ // eslint-disable-next-line mozilla/reject-some-requires
+} = require("resource://devtools/client/netmonitor/src/utils/request-utils.js");
+
+module.exports = function ({ resource }) {
+ resource.urlDetails = getUrlDetails(resource.url);
+ resource.startedMs = Date.parse(resource.startedDateTime);
+ return resource;
+};
diff --git a/devtools/shared/commands/resource/transformers/storage-cache.js b/devtools/shared/commands/resource/transformers/storage-cache.js
new file mode 100644
index 0000000000..245d892041
--- /dev/null
+++ b/devtools/shared/commands/resource/transformers/storage-cache.js
@@ -0,0 +1,22 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const {
+ TYPES: { CACHE_STORAGE },
+} = require("resource://devtools/shared/commands/resource/resource-command.js");
+
+const { Front, types } = require("resource://devtools/shared/protocol.js");
+
+module.exports = function ({ resource, watcherFront, targetFront }) {
+ if (!(resource instanceof Front) && watcherFront) {
+ // instantiate front for local storage
+ resource = types.getType("Cache").read(resource, targetFront);
+ resource.resourceType = CACHE_STORAGE;
+ resource.resourceKey = "Cache";
+ }
+
+ return resource;
+};
diff --git a/devtools/shared/commands/resource/transformers/storage-cookie.js b/devtools/shared/commands/resource/transformers/storage-cookie.js
new file mode 100644
index 0000000000..23e221672b
--- /dev/null
+++ b/devtools/shared/commands/resource/transformers/storage-cookie.js
@@ -0,0 +1,26 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const {
+ TYPES: { COOKIE },
+} = require("resource://devtools/shared/commands/resource/resource-command.js");
+
+const { Front, types } = require("resource://devtools/shared/protocol.js");
+
+module.exports = function ({ resource, watcherFront, targetFront }) {
+ if (!(resource instanceof Front) && watcherFront) {
+ const { innerWindowId } = resource;
+
+ // it's safe to instantiate the front now, so we do it.
+ resource = types.getType("cookies").read(resource, targetFront);
+ resource.resourceType = COOKIE;
+ resource.resourceId = `${COOKIE}-${targetFront.browsingContextID}`;
+ resource.resourceKey = "cookies";
+ resource.innerWindowId = innerWindowId;
+ }
+
+ return resource;
+};
diff --git a/devtools/shared/commands/resource/transformers/storage-extension.js b/devtools/shared/commands/resource/transformers/storage-extension.js
new file mode 100644
index 0000000000..3e40bdd6d0
--- /dev/null
+++ b/devtools/shared/commands/resource/transformers/storage-extension.js
@@ -0,0 +1,26 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const {
+ TYPES: { EXTENSION_STORAGE },
+} = require("resource://devtools/shared/commands/resource/resource-command.js");
+
+const { Front, types } = require("resource://devtools/shared/protocol.js");
+
+module.exports = function ({ resource, watcherFront, targetFront }) {
+ if (!(resource instanceof Front) && watcherFront) {
+ const { innerWindowId } = resource;
+
+ // it's safe to instantiate the front now, so we do it.
+ resource = types.getType("extensionStorage").read(resource, targetFront);
+ resource.resourceType = EXTENSION_STORAGE;
+ resource.resourceId = `${EXTENSION_STORAGE}-${targetFront.browsingContextID}`;
+ resource.resourceKey = "extensionStorage";
+ resource.innerWindowId = innerWindowId;
+ }
+
+ return resource;
+};
diff --git a/devtools/shared/commands/resource/transformers/storage-indexed-db.js b/devtools/shared/commands/resource/transformers/storage-indexed-db.js
new file mode 100644
index 0000000000..8021719070
--- /dev/null
+++ b/devtools/shared/commands/resource/transformers/storage-indexed-db.js
@@ -0,0 +1,26 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const {
+ TYPES: { INDEXED_DB },
+} = require("resource://devtools/shared/commands/resource/resource-command.js");
+
+const { Front, types } = require("resource://devtools/shared/protocol.js");
+
+module.exports = function ({ resource, watcherFront, targetFront }) {
+ if (!(resource instanceof Front) && watcherFront) {
+ const { innerWindowId } = resource;
+
+ // it's safe to instantiate the front now, so we do it.
+ resource = types.getType("indexedDB").read(resource, targetFront);
+ resource.resourceType = INDEXED_DB;
+ resource.resourceId = `${INDEXED_DB}-${targetFront.browsingContextID}`;
+ resource.resourceKey = "indexedDB";
+ resource.innerWindowId = innerWindowId;
+ }
+
+ return resource;
+};
diff --git a/devtools/shared/commands/resource/transformers/storage-local-storage.js b/devtools/shared/commands/resource/transformers/storage-local-storage.js
new file mode 100644
index 0000000000..13488723f3
--- /dev/null
+++ b/devtools/shared/commands/resource/transformers/storage-local-storage.js
@@ -0,0 +1,22 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const {
+ TYPES: { LOCAL_STORAGE },
+} = require("resource://devtools/shared/commands/resource/resource-command.js");
+
+const { Front, types } = require("resource://devtools/shared/protocol.js");
+
+module.exports = function ({ resource, watcherFront, targetFront }) {
+ if (!(resource instanceof Front) && watcherFront) {
+ // instantiate front for local storage
+ resource = types.getType("localStorage").read(resource, targetFront);
+ resource.resourceType = LOCAL_STORAGE;
+ resource.resourceKey = "localStorage";
+ }
+
+ return resource;
+};
diff --git a/devtools/shared/commands/resource/transformers/storage-session-storage.js b/devtools/shared/commands/resource/transformers/storage-session-storage.js
new file mode 100644
index 0000000000..ab9f1361c8
--- /dev/null
+++ b/devtools/shared/commands/resource/transformers/storage-session-storage.js
@@ -0,0 +1,22 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const {
+ TYPES: { SESSION_STORAGE },
+} = require("resource://devtools/shared/commands/resource/resource-command.js");
+
+const { Front, types } = require("resource://devtools/shared/protocol.js");
+
+module.exports = function ({ resource, watcherFront, targetFront }) {
+ if (!(resource instanceof Front) && watcherFront) {
+ // instantiate front for session storage
+ resource = types.getType("sessionStorage").read(resource, targetFront);
+ resource.resourceType = SESSION_STORAGE;
+ resource.resourceKey = "sessionStorage";
+ }
+
+ return resource;
+};
diff --git a/devtools/shared/commands/resource/transformers/thread-states.js b/devtools/shared/commands/resource/transformers/thread-states.js
new file mode 100644
index 0000000000..1564585b36
--- /dev/null
+++ b/devtools/shared/commands/resource/transformers/thread-states.js
@@ -0,0 +1,32 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const { Front, types } = require("resource://devtools/shared/protocol.js");
+
+module.exports = function ({ resource, watcherFront, targetFront }) {
+ // only "paused" have a frame attribute, and legacy listeners are already passing a FrameFront
+ if (resource.frame && !(resource.frame instanceof Front)) {
+ // Use ThreadFront as parent as debugger's commands.js expects FrameFront to be children
+ // of the ThreadFront.
+ resource.frame = types
+ .getType("frame")
+ .read(resource.frame, targetFront.threadFront);
+ }
+
+ // If we are using server side request (i.e. watcherFront is defined)
+ // Fake paused and resumed events as the thread front depends on them.
+ // We can't emit "EventEmitter" events, as ThreadFront uses `Front.before`
+ // to listen for paused and resumed. ("before" is part of protocol.js Front and not part of EventEmitter)
+ if (watcherFront) {
+ if (resource.state == "paused") {
+ targetFront.threadFront._beforePaused(resource);
+ } else if (resource.state == "resumed") {
+ targetFront.threadFront._beforeResumed(resource);
+ }
+ }
+
+ return resource;
+};