Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--HG-- rename : mobile/android/chrome/content/PluginHelper.js => browser/metro/base/content/contenthandlers/PluginHelper.js
- Loading branch information
Showing
42 changed files
with
1,368 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"revision": "823616f0af83eca32bceb0367a7a221f8b187110", | ||
"revision": "b2b0a8234336f7004812bf27e4053957cecad492", | ||
"repo_path": "/integration/gaia-central" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
browser/devtools/webconsole/test/browser_webconsole_cd_iframe.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
// Test that the cd() jsterm helper function works as expected. See bug 609872. | ||
|
||
function test() { | ||
let hud; | ||
|
||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug-609872-cd-iframe-parent.html"; | ||
|
||
const parentMessages = [{ | ||
name: "document.title in parent iframe", | ||
text: "bug 609872 - iframe parent", | ||
category: CATEGORY_OUTPUT, | ||
}, { | ||
name: "paragraph content", | ||
text: "p: test for bug 609872 - iframe parent", | ||
category: CATEGORY_OUTPUT, | ||
}, { | ||
name: "object content", | ||
text: "obj: parent!", | ||
category: CATEGORY_OUTPUT, | ||
}]; | ||
|
||
const childMessages = [{ | ||
name: "document.title in child iframe", | ||
text: "bug 609872 - iframe child", | ||
category: CATEGORY_OUTPUT, | ||
}, { | ||
name: "paragraph content", | ||
text: "p: test for bug 609872 - iframe child", | ||
category: CATEGORY_OUTPUT, | ||
}, { | ||
name: "object content", | ||
text: "obj: child!", | ||
category: CATEGORY_OUTPUT, | ||
}]; | ||
|
||
Task.spawn(runner).then(finishTest); | ||
|
||
function* runner() { | ||
const {tab} = yield loadTab(TEST_URI); | ||
hud = yield openConsole(tab); | ||
|
||
executeWindowTest(); | ||
|
||
yield waitForMessages({ webconsole: hud, messages: parentMessages }); | ||
|
||
info("cd() into the iframe using a selector"); | ||
hud.jsterm.clearOutput(); | ||
hud.jsterm.execute("cd('iframe')"); | ||
executeWindowTest(); | ||
|
||
yield waitForMessages({ webconsole: hud, messages: childMessages }); | ||
|
||
info("cd() out of the iframe, reset to default window"); | ||
hud.jsterm.clearOutput(); | ||
hud.jsterm.execute("cd()"); | ||
executeWindowTest(); | ||
|
||
yield waitForMessages({ webconsole: hud, messages: parentMessages }); | ||
|
||
info("call cd() with unexpected arguments"); | ||
hud.jsterm.clearOutput(); | ||
hud.jsterm.execute("cd(document)"); | ||
|
||
yield waitForMessages({ | ||
webconsole: hud, | ||
messages: [{ | ||
text: "Cannot cd()", | ||
category: CATEGORY_OUTPUT, | ||
severity: SEVERITY_ERROR, | ||
}], | ||
}); | ||
|
||
hud.jsterm.clearOutput(); | ||
hud.jsterm.execute("cd('p')"); | ||
|
||
yield waitForMessages({ | ||
webconsole: hud, | ||
messages: [{ | ||
text: "Cannot cd()", | ||
category: CATEGORY_OUTPUT, | ||
severity: SEVERITY_ERROR, | ||
}], | ||
}); | ||
|
||
info("cd() into the iframe using an iframe DOM element"); | ||
hud.jsterm.clearOutput(); | ||
hud.jsterm.execute("cd($('iframe'))"); | ||
executeWindowTest(); | ||
|
||
yield waitForMessages({ webconsole: hud, messages: childMessages }); | ||
|
||
info("cd(window.parent)"); | ||
hud.jsterm.clearOutput(); | ||
hud.jsterm.execute("cd(window.parent)"); | ||
executeWindowTest(); | ||
|
||
yield waitForMessages({ webconsole: hud, messages: parentMessages }); | ||
|
||
yield closeConsole(tab); | ||
} | ||
|
||
function executeWindowTest() { | ||
hud.jsterm.execute("document.title"); | ||
hud.jsterm.execute("'p: ' + document.querySelector('p').textContent"); | ||
hud.jsterm.execute("'obj: ' + window.foobarBug609872"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
browser/devtools/webconsole/test/test-bug-609872-cd-iframe-child.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>test for bug 609872 - iframe child</title> | ||
<!-- Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ --> | ||
</head> | ||
<body> | ||
<p>test for bug 609872 - iframe child</p> | ||
<script>window.foobarBug609872 = 'child!';</script> | ||
</body> | ||
</html> |
14 changes: 14 additions & 0 deletions
14
browser/devtools/webconsole/test/test-bug-609872-cd-iframe-parent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>test for bug 609872 - iframe parent</title> | ||
<!-- Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ --> | ||
</head> | ||
<body> | ||
<p>test for bug 609872 - iframe parent</p> | ||
<script>window.foobarBug609872 = 'parent!';</script> | ||
<iframe src="test-bug-609872-cd-iframe-child.html"></iframe> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
browser/metro/base/content/contenthandlers/PluginHelper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* 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"; | ||
|
||
dump("### PluginHelper.js loaded\n"); | ||
|
||
/** | ||
* Handle events generated by plugin click-to-play code. | ||
* | ||
* This "PluginBindingAttached" fires when a "pluginProblem" XBL binding is | ||
* created. This binding overlays plugin content when the plugin is missing, | ||
* blocked, click-to-play, or replaced by a "preview" extension plugin like | ||
* Shumway or PDF.js. | ||
*/ | ||
var PluginHelper = { | ||
init: function () { | ||
addEventListener("PluginBindingAttached", this, true, true); | ||
}, | ||
|
||
handleEvent: function handleEvent(aEvent) { | ||
switch (aEvent.type) { | ||
case "PluginBindingAttached": | ||
this.handlePluginBindingAttached(aEvent); | ||
break; | ||
} | ||
}, | ||
|
||
getPluginMimeType: function (plugin) { | ||
var tagMimetype = plugin.actualType; | ||
|
||
if (tagMimetype == "") { | ||
tagMimetype = plugin.type; | ||
} | ||
return tagMimetype; | ||
}, | ||
|
||
handlePluginBindingAttached: function (aEvent) { | ||
let plugin = aEvent.target; | ||
let doc = plugin.ownerDocument; | ||
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); | ||
if (!overlay || overlay._bindingHandled) { | ||
return; | ||
} | ||
overlay._bindingHandled = true; | ||
|
||
let eventType = PluginHelper._getBindingType(plugin); | ||
if (!eventType) { | ||
return; | ||
} | ||
|
||
switch (eventType) { | ||
case "PluginPlayPreview": { | ||
// Load the "preview" handler (an extension plugin like Shumway or PDF.js). | ||
let previewContent = doc.getAnonymousElementByAttribute(plugin, "class", "previewPluginContent"); | ||
let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); | ||
let mimeType = PluginHelper.getPluginMimeType(plugin); | ||
let playPreviewInfo = pluginHost.getPlayPreviewInfo(mimeType); | ||
|
||
let iframe = previewContent.getElementsByClassName("previewPluginContentFrame")[0]; | ||
if (!iframe) { | ||
// lazy initialization of the iframe | ||
iframe = doc.createElementNS("http://www.w3.org/1999/xhtml", "iframe"); | ||
iframe.className = "previewPluginContentFrame"; | ||
previewContent.appendChild(iframe); | ||
} | ||
iframe.src = playPreviewInfo.redirectURL; | ||
break; | ||
} | ||
|
||
case "PluginNotFound": { | ||
// TODO: Display a message about missing plugins (bug 936907) | ||
break; | ||
} | ||
} | ||
}, | ||
|
||
// Helper to get the binding handler type from a plugin object | ||
_getBindingType: function(plugin) { | ||
if (!(plugin instanceof Ci.nsIObjectLoadingContent)) | ||
return null; | ||
|
||
switch (plugin.pluginFallbackType) { | ||
case Ci.nsIObjectLoadingContent.PLUGIN_UNSUPPORTED: | ||
return "PluginNotFound"; | ||
case Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW: | ||
return "PluginPlayPreview"; | ||
default: | ||
// Metro Firefox does not yet support other fallback types. | ||
return null; | ||
} | ||
}, | ||
}; | ||
|
||
PluginHelper.init(); |
Oops, something went wrong.