Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit d27edc0

Browse files
committed
Handle XULDocument in the Document rep.
Add a stub and a test to make sure we don't regress this. Fixes #933. And fixes https://bugzilla.mozilla.org/show_bug.cgi\?id\=1438454 .
1 parent 3e7466e commit d27edc0

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

packages/devtools-reps/src/reps/document.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ function supportsObject(object, noGrip = false) {
6161
return false;
6262
}
6363

64-
return (object.preview && getGripType(object, noGrip) == "HTMLDocument");
64+
const type = getGripType(object, noGrip);
65+
return (object.preview && (type === "HTMLDocument" || type === "XULDocument"));
6566
}
6667

6768
// Exports from this module

packages/devtools-reps/src/reps/stubs/document.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,21 @@ stubs.set("Location-less Document", {
3434
}
3535
});
3636

37+
stubs.set("XULDocument", {
38+
"type": "object",
39+
"actor": "server1.conn0.obj434",
40+
"class": "XULDocument",
41+
"extensible": true,
42+
"frozen": false,
43+
"sealed": false,
44+
"ownPropertyLength": 1,
45+
"preview": {
46+
"kind": "DOMNode",
47+
"nodeType": 9,
48+
"nodeName": "#document",
49+
"isConnected": true,
50+
"location": "chrome://browser/content/browser.xul"
51+
}
52+
});
53+
3754
module.exports = stubs;

packages/devtools-reps/src/reps/tests/document.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ const {
1414

1515
const { Document } = REPS;
1616
const stubs = require("../stubs/document");
17-
const stub = stubs.get("Document");
1817

1918
describe("Document", () => {
19+
const stub = stubs.get("Document");
2020
it("correctly selects Document Rep", () => {
2121
expect(getRep(stub)).toBe(Document.rep);
2222
});
@@ -39,3 +39,20 @@ describe("Document", () => {
3939
expect(renderedComponent.text()).toEqual("HTMLDocument");
4040
});
4141
});
42+
43+
describe("XULDocument", () => {
44+
const stub = stubs.get("XULDocument");
45+
it("correctly selects Document Rep", () => {
46+
expect(getRep(stub)).toBe(Document.rep);
47+
});
48+
49+
it("renders with expected text content", () => {
50+
const renderedComponent = shallow(Document.rep({
51+
object: stub
52+
}));
53+
54+
expect(renderedComponent.text())
55+
.toEqual("XULDocument chrome://browser/content/browser.xul");
56+
expectActorAttribute(renderedComponent, stub.actor);
57+
});
58+
});

0 commit comments

Comments
 (0)