forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mozilla#29 from KershawChang/bug_1268810
Bug 1268810
- Loading branch information
Showing
8 changed files
with
206 additions
and
9 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
60 changes: 60 additions & 0 deletions
60
dom/presentation/tests/mochitest/file_presentation_receiver_auxiliary_navigation.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,60 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test for sandboxed auxiliary navigation flag in receiver page</title> | ||
</head> | ||
<body> | ||
<div id="content"></div> | ||
<script type="application/javascript;version=1.7"> | ||
|
||
"use strict"; | ||
|
||
function is(a, b, msg) { | ||
alert((a === b ? 'OK ' : 'KO ') + msg); | ||
} | ||
|
||
function ok(a, msg) { | ||
alert((a ? 'OK ' : 'KO ') + msg); | ||
} | ||
|
||
function info(msg) { | ||
alert('INFO ' + msg); | ||
} | ||
|
||
function command(msg) { | ||
alert('COMMAND ' + JSON.stringify(msg)); | ||
} | ||
|
||
function finish() { | ||
alert('DONE'); | ||
} | ||
|
||
function testConnectionAvailable() { | ||
return new Promise(function(aResolve, aReject) { | ||
ok(navigator.presentation, "navigator.presentation should be available in OOP receiving pages."); | ||
ok(navigator.presentation.receiver, "navigator.presentation.receiver should be available in receiving pages."); | ||
|
||
aResolve(); | ||
}); | ||
} | ||
|
||
function testOpenWindow() { | ||
return new Promise(function(aResolve, aReject) { | ||
try { | ||
window.open("http://example.com"); | ||
ok(false, "receiver page should not be able to open a new window."); | ||
} catch(e) { | ||
ok(true, "receiver page should not be able to open a new window."); | ||
aResolve(); | ||
} | ||
}); | ||
} | ||
|
||
testConnectionAvailable(). | ||
then(testOpenWindow). | ||
then(finish); | ||
|
||
</script> | ||
</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
75 changes: 75 additions & 0 deletions
75
dom/presentation/tests/mochitest/test_presentation_receiver_auxiliary_navigation.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,75 @@ | ||
"use strict"; | ||
|
||
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("PresentationSessionChromeScript.js")); | ||
var receiverUrl = SimpleTest.getTestFileURL("file_presentation_receiver_auxiliary_navigation.html"); | ||
|
||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"] | ||
.getService(SpecialPowers.Ci.nsIObserverService); | ||
|
||
function setup() { | ||
return new Promise(function(aResolve, aReject) { | ||
gScript.sendAsyncMessage("trigger-device-add"); | ||
|
||
var iframe = document.createElement("iframe"); | ||
iframe.setAttribute("mozbrowser", "true"); | ||
iframe.setAttribute("mozpresentation", receiverUrl); | ||
var oop = location.pathname.indexOf('_inproc') == -1; | ||
iframe.setAttribute("remote", oop); | ||
iframe.setAttribute("src", receiverUrl); | ||
|
||
// This event is triggered when the iframe calls "postMessage". | ||
iframe.addEventListener("mozbrowsershowmodalprompt", function listener(aEvent) { | ||
var message = aEvent.detail.message; | ||
if (/^OK /.exec(message)) { | ||
ok(true, "Message from iframe: " + message); | ||
} else if (/^KO /.exec(message)) { | ||
ok(false, "Message from iframe: " + message); | ||
} else if (/^INFO /.exec(message)) { | ||
info("Message from iframe: " + message); | ||
} else if (/^COMMAND /.exec(message)) { | ||
var command = JSON.parse(message.replace(/^COMMAND /, "")); | ||
gScript.sendAsyncMessage(command.name, command.data); | ||
} else if (/^DONE$/.exec(message)) { | ||
ok(true, "Messaging from iframe complete."); | ||
iframe.removeEventListener("mozbrowsershowmodalprompt", listener); | ||
|
||
teardown(); | ||
} | ||
}, false); | ||
|
||
var promise = new Promise(function(aResolve, aReject) { | ||
document.body.appendChild(iframe); | ||
|
||
aResolve(iframe); | ||
}); | ||
obs.notifyObservers(promise, "setup-request-promise", null); | ||
|
||
aResolve(); | ||
}); | ||
} | ||
|
||
function teardown() { | ||
gScript.addMessageListener("teardown-complete", function teardownCompleteHandler() { | ||
gScript.removeMessageListener("teardown-complete", teardownCompleteHandler); | ||
gScript.destroy(); | ||
SimpleTest.finish(); | ||
}); | ||
|
||
gScript.sendAsyncMessage("teardown"); | ||
} | ||
|
||
function runTests() { | ||
setup().then(); | ||
} | ||
|
||
SimpleTest.waitForExplicitFinish(); | ||
SpecialPowers.pushPermissions([ | ||
{type: "presentation-device-manage", allow: false, context: document}, | ||
{type: "presentation", allow: true, context: document}, | ||
{type: "browser", allow: true, context: document}, | ||
], function() { | ||
SpecialPowers.pushPrefEnv({ "set": [["dom.presentation.enabled", true], | ||
["dom.mozBrowserFramesEnabled", true], | ||
["dom.presentation.session_transport.data_channel.enable", false]]}, | ||
runTests); | ||
}); |
18 changes: 18 additions & 0 deletions
18
dom/presentation/tests/mochitest/test_presentation_receiver_auxiliary_navigation_inproc.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,18 @@ | ||
<!DOCTYPE HTML> | ||
<!-- vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: --> | ||
<html> | ||
<!-- Any copyright is dedicated to the Public Domain. | ||
- http://creativecommons.org/publicdomain/zero/1.0/ --> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test for B2G Presentation API when sender and receiver at the same side</title> | ||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> | ||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> | ||
</head> | ||
<body> | ||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1268810"> | ||
Test for receiver page with sandboxed auxiliary navigation browsing context flag.</a> | ||
<script type="application/javascript;version=1.8" src="test_presentation_receiver_auxiliary_navigation.js"> | ||
</script> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
dom/presentation/tests/mochitest/test_presentation_receiver_auxiliary_navigation_oop.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,18 @@ | ||
<!DOCTYPE HTML> | ||
<!-- vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: --> | ||
<html> | ||
<!-- Any copyright is dedicated to the Public Domain. | ||
- http://creativecommons.org/publicdomain/zero/1.0/ --> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test for B2G Presentation API when sender and receiver at the same side</title> | ||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> | ||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> | ||
</head> | ||
<body> | ||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1268810"> | ||
Test for receiver page with sandboxed auxiliary navigation browsing context flag.</a> | ||
<script type="application/javascript;version=1.8" src="test_presentation_receiver_auxiliary_navigation.js"> | ||
</script> | ||
</body> | ||
</html> |