summaryrefslogtreecommitdiffstats
path: root/devtools/server/actors/targets/frame.js
blob: cd9d97f02698a3dfe7cc07f02eab4c23be8f6975 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* 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";

/*
 * Target actor for a frame / docShell in the content process (where the actual
 * content lives).
 *
 * This actor extends BrowsingContextTargetActor.
 *
 * See devtools/docs/backend/actor-hierarchy.md for more details.
 */

var {
  BrowsingContextTargetActor,
  browsingContextTargetPrototype,
} = require("devtools/server/actors/targets/browsing-context");

const { extend } = require("devtools/shared/extend");
const { frameTargetSpec } = require("devtools/shared/specs/targets/frame");
const Targets = require("devtools/server/actors/targets/index");
const TargetActorMixin = require("devtools/server/actors/targets/target-actor-mixin");

/**
 * Protocol.js expects only the prototype object, and does not maintain the prototype
 * chain when it constructs the ActorClass. For this reason we are using `extend` to
 * maintain the properties of BrowsingContextTargetActor.prototype
 */
const frameTargetPrototype = extend({}, browsingContextTargetPrototype);

/**
 * Target actor for a frame / docShell in the content process.
 *
 * @param connection DevToolsServerConnection
 *        The conection to the client.
 * @param docShell nsIDocShell
 *        The |docShell| for the debugged frame.
 * @param options Object
 *        See BrowsingContextTargetActor.initialize doc.
 */
frameTargetPrototype.initialize = function(connection, docShell, options) {
  BrowsingContextTargetActor.prototype.initialize.call(
    this,
    connection,
    docShell,
    options
  );

  this.traits.reconfigure = false;
};

Object.defineProperty(frameTargetPrototype, "title", {
  get: function() {
    return this.window.document.title;
  },
  enumerable: true,
  configurable: true,
});

exports.FrameTargetActor = TargetActorMixin(
  Targets.TYPES.FRAME,
  frameTargetSpec,
  frameTargetPrototype
);