forked from Floorp-Projects/Floorp
-
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.
Bug 1148033 - BroadcastChannel API should rispect the B2G app sandbox…
…es, r=ehsan
- Loading branch information
Showing
11 changed files
with
462 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[DEFAULT] | ||
skip-if = buildapp == 'b2g' | ||
skip-if = e10s || buildapp == 'b2g' | ||
support-files = | ||
blank.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,20 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>MozBrowser iframe</title> | ||
</head> | ||
<body> | ||
<div id="container"></div> | ||
<script type="application/javascript;version=1.7"> | ||
|
||
var ifr = document.createElement('iframe'); | ||
ifr.src = 'http://mochi.test:8888/tests/dom/broadcastchannel/tests/iframe_mozbrowser.html'; | ||
ifr.onload = function() { alert('DONE'); } | ||
|
||
var domParent = document.getElementById('container'); | ||
domParent.appendChild(ifr); | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>MozBrowser iframe</title> | ||
</head> | ||
<body> | ||
<div id="container"></div> | ||
<script type="application/javascript;version=1.7"> | ||
|
||
var ifr = document.createElement('iframe'); | ||
ifr.setAttribute('mozbrowser', true); | ||
ifr.src = 'http://mochi.test:8888/tests/dom/broadcastchannel/tests/iframe_mozbrowser2.html'; | ||
ifr.onload = function() { alert('DONE'); } | ||
|
||
var domParent = document.getElementById('container'); | ||
domParent.appendChild(ifr); | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>MozBrowser iframe</title> | ||
</head> | ||
<body> | ||
<script type="application/javascript;version=1.7"> | ||
|
||
var bc = new BroadcastChannel('foobar'); | ||
bc.postMessage('This is wrong!'); | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>MozBrowser iframe</title> | ||
</head> | ||
<body> | ||
<script type="application/javascript;version=1.7"> | ||
|
||
var bc = new BroadcastChannel('foobar'); | ||
bc.postMessage('This is wrong!'); | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "BroadcastChannel", | ||
"description": "BroadcastChannel app", | ||
"launch_path": "/tests/dom/broadcastchannel/tests/TESTTOKEN", | ||
"icons": { "128": "default_icon" } | ||
} |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
var gBasePath = "tests/dom/broadcastchannel/tests/"; | ||
|
||
function handleRequest(request, response) { | ||
var query = getQuery(request); | ||
|
||
var testToken = ''; | ||
if ('testToken' in query) { | ||
testToken = query.testToken; | ||
} | ||
|
||
var template = 'manifest.webapp'; | ||
if ('template' in query) { | ||
template = query.template; | ||
} | ||
var template = gBasePath + template; | ||
response.setHeader("Content-Type", "application/x-web-app-manifest+json", false); | ||
response.write(readTemplate(template).replace(/TESTTOKEN/g, testToken)); | ||
} | ||
|
||
// Copy-pasted incantations. There ought to be a better way to synchronously read | ||
// a file into a string, but I guess we're trying to discourage that. | ||
function readTemplate(path) { | ||
var file = Components.classes["@mozilla.org/file/directory_service;1"]. | ||
getService(Components.interfaces.nsIProperties). | ||
get("CurWorkD", Components.interfaces.nsILocalFile); | ||
var fis = Components.classes['@mozilla.org/network/file-input-stream;1']. | ||
createInstance(Components.interfaces.nsIFileInputStream); | ||
var cis = Components.classes["@mozilla.org/intl/converter-input-stream;1"]. | ||
createInstance(Components.interfaces.nsIConverterInputStream); | ||
var split = path.split("/"); | ||
for(var i = 0; i < split.length; ++i) { | ||
file.append(split[i]); | ||
} | ||
fis.init(file, -1, -1, false); | ||
cis.init(fis, "UTF-8", 0, 0); | ||
|
||
var data = ""; | ||
let str = {}; | ||
let read = 0; | ||
do { | ||
read = cis.readString(0xffffffff, str); // read as much as we can and put it in str.value | ||
data += str.value; | ||
} while (read != 0); | ||
cis.close(); | ||
return data; | ||
} | ||
|
||
function getQuery(request) { | ||
var query = {}; | ||
request.queryString.split('&').forEach(function (val) { | ||
var [name, value] = val.split('='); | ||
query[name] = unescape(value); | ||
}); | ||
return query; | ||
} | ||
|
Oops, something went wrong.