Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1829 from Gozala/dev-panel-chrome
Browse files Browse the repository at this point in the history
Bug 1075490 - Fix devtools docking. r=@ochameau
  • Loading branch information
Gozala committed Apr 22, 2015
2 parents d52ba0b + 083eed7 commit 26182ea
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 9 deletions.
13 changes: 9 additions & 4 deletions lib/dev/frame-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ addMessageListener("sdk/event/message", onInMessage);
addMessageListener("sdk/port/message", onInPort);

const observer = {
handleEvent: ({target, type}) => {
observer.observe(target, type);
},
observe: (document, topic, data) => {
// When frame associated with message manager is removed from document `docShell`
// is set to `null` but observer is still kept alive. At this point accesing
Expand All @@ -82,21 +85,21 @@ const observer = {
observerService.removeObserver(observer, topic);
}
else if (document === content.document) {
if (topic === "content-document-interactive") {
if (topic.endsWith("-document-interactive")) {
sendAsyncMessage("sdk/event/ready", {
type: "ready",
readyState: document.readyState,
uri: document.documentURI
});
}
if (topic === "content-document-loaded") {
if (topic.endsWith("-document-loaded")) {
sendAsyncMessage("sdk/event/load", {
type: "load",
readyState: document.readyState,
uri: document.documentURI
});
}
if (topic === "content-page-hidden") {
if (topic === "unload") {
channels.clear();
sendAsyncMessage("sdk/event/unload", {
type: "unload",
Expand All @@ -110,6 +113,8 @@ const observer = {

observerService.addObserver(observer, "content-document-interactive", false);
observerService.addObserver(observer, "content-document-loaded", false);
observerService.addObserver(observer, "content-page-hidden", false);
observerService.addObserver(observer, "chrome-document-interactive", false);
observerService.addObserver(observer, "chrome-document-loaded", false);
addEventListener("unload", observer, false);

})(this);
10 changes: 5 additions & 5 deletions lib/dev/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ createView.define(Panel, (panel, document) => {
const frame = document.createElement("iframe");
setAttributes(frame, {
"sandbox": "allow-scripts",
// It would be great if we could allow remote iframes for sandboxing
// panel documents in a content process, but for now platform implementation
// is buggy on linux so this is disabled.
// "remote": true,
"type": "content",
// We end up using chrome iframe with forced message manager
// as fixing a swapFrameLoader seemed like a giant task (see
// Bug 1075490).
"type": "chrome",
"forcemessagemanager": true,
"transparent": true,
"seamless": "seamless",
});
Expand Down
49 changes: 49 additions & 0 deletions test/test-dev-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,55 @@ exports["test Panel API"] = test(function*(assert) {
myTool.destroy();
});

exports["test forbid remote https docs"] = test(function*(assert) {
const MyPanel = Class({
extends: Panel,
label: "test https panel",
tooltip: "my test panel",
icon: iconURI,
url: "https://mozilla.org",
});

assert.throws(() => {
new Tool({ panels: { myPanel: MyPanel } });
},
/The `options.url` must be a valid local URI/,
"can't use panel with remote URI");
});

exports["test forbid remote http docs"] = test(function*(assert) {
const MyPanel = Class({
extends: Panel,
label: "test http panel",
tooltip: "my test panel",
icon: iconURI,
url: "http://arewefastyet.com/",
});

assert.throws(() => {
new Tool({ panels: { myPanel: MyPanel } });
},
/The `options.url` must be a valid local URI/,
"can't use panel with remote URI");
});

exports["test forbid remote ftp docs"] = test(function*(assert) {
const MyPanel = Class({
extends: Panel,
label: "test ftp panel",
tooltip: "my test panel",
icon: iconURI,
url: "ftp://ftp.mozilla.org/",
});

assert.throws(() => {
new Tool({ panels: { myPanel: MyPanel } });
},
/The `options.url` must be a valid local URI/,
"can't use panel with remote URI");
});


exports["test Panel communication"] = test(function*(assert) {
const MyPanel = Class({
extends: Panel,
Expand Down

0 comments on commit 26182ea

Please sign in to comment.