summaryrefslogtreecommitdiffstats
path: root/devtools/shared/commands/script/tests/browser_script_command_execute_document__proto__.js
blob: 28f56ebac33ae8e8e10794b545111dff2c8ba329 (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
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Testing evaluating document.__proto__

add_task(async () => {
  const tab = await addTab(
    `data:text/html;charset=utf-8,Test evaluating document.__proto__`
  );
  const commands = await CommandsFactory.forTab(tab);
  await commands.targetCommand.startListening();

  const evaluationResponse = await commands.scriptCommand.execute(
    "document.__proto__"
  );
  checkObject(evaluationResponse, {
    input: "document.__proto__",
    result: {
      type: "object",
      actor: /[a-z]/,
    },
  });

  ok(!evaluationResponse.exception, "no eval exception");
  ok(!evaluationResponse.helperResult, "no helper result");

  const response = await evaluationResponse.result.getPrototypeAndProperties();
  ok(!response.error, "no response error");

  const props = response.ownProperties;
  ok(props, "response properties available");

  const expectedProps = Object.getOwnPropertyNames(
    Object.getPrototypeOf(document)
  );
  checkObject(Object.keys(props), expectedProps, "Same own properties.");

  await commands.destroy();
});