зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-c to b2g-inbound
This commit is contained in:
Коммит
10e51c6aaa
|
@ -313,7 +313,7 @@ var gPluginHandler = {
|
|||
break;
|
||||
}
|
||||
|
||||
// Hide the in-content UI if it's too big. The crashed plugin handler already did this.
|
||||
// Show the in-content UI if it's not too big. The crashed plugin handler already did this.
|
||||
if (eventType != "PluginCrashed" && eventType != "PluginRemoved") {
|
||||
let overlay = this.getPluginUI(plugin, "main");
|
||||
if (overlay != null) {
|
||||
|
@ -989,12 +989,12 @@ var gPluginHandler = {
|
|||
if (this.isTooSmall(plugin, overlay)) {
|
||||
// Hide the overlay's contents. Use visibility style, so that it doesn't
|
||||
// collapse down to 0x0.
|
||||
overlay.style.visibility = "hidden";
|
||||
isShowing = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isShowing) {
|
||||
overlay.style.visibility = "visible";
|
||||
// If a previous plugin on the page was too small and resulted in adding a
|
||||
// notification bar, then remove it because this plugin instance it big
|
||||
// enough to serve as in-content notification.
|
||||
|
|
|
@ -575,7 +575,7 @@
|
|||
.variable-or-property[non-configurable] > tooltip > label[value=configurable],
|
||||
.variable-or-property[non-writable] > tooltip > label[value=writable],
|
||||
.variable-or-property[non-extensible] > tooltip > label[value=extensible] {
|
||||
color: #800;
|
||||
color: #f44;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
|
|
|
@ -924,6 +924,7 @@ nsContentUtils::ParseSandboxAttributeToFlags(const nsAString& aSandboxAttrValue)
|
|||
// If there's a sandbox attribute at all (and there is if this is being
|
||||
// called), start off by setting all the restriction flags.
|
||||
uint32_t out = SANDBOXED_NAVIGATION |
|
||||
SANDBOXED_AUXILIARY_NAVIGATION |
|
||||
SANDBOXED_TOPLEVEL_NAVIGATION |
|
||||
SANDBOXED_PLUGINS |
|
||||
SANDBOXED_ORIGIN |
|
||||
|
@ -954,6 +955,8 @@ nsContentUtils::ParseSandboxAttributeToFlags(const nsAString& aSandboxAttrValue)
|
|||
out &= ~SANDBOXED_TOPLEVEL_NAVIGATION;
|
||||
} else if (token.LowerCaseEqualsLiteral("allow-pointer-lock")) {
|
||||
out &= ~SANDBOXED_POINTER_LOCK;
|
||||
} else if (token.LowerCaseEqualsLiteral("allow-popups")) {
|
||||
out &= ~SANDBOXED_AUXILIARY_NAVIGATION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5219,7 +5219,7 @@ nsDocument::Register(JSContext* aCx, const nsAString& aName,
|
|||
// If a prototype is provided, we must check to ensure that it inherits
|
||||
// from HTMLElement.
|
||||
protoObject = aOptions.mPrototype;
|
||||
if (!JS_WrapObject(aCx, protoObject.address())) {
|
||||
if (!JS_WrapObject(aCx, &protoObject)) {
|
||||
rv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -230,14 +230,13 @@ mozilla::dom::ipc::UnpackClonedMessageDataForChild(const ClonedMessageData& aDat
|
|||
}
|
||||
|
||||
bool
|
||||
SameProcessCpowHolder::ToObject(JSContext* aCx, JSObject** aObjp)
|
||||
SameProcessCpowHolder::ToObject(JSContext* aCx, JS::MutableHandleObject aObjp)
|
||||
{
|
||||
*aObjp = mObj;
|
||||
|
||||
if (!mObj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
aObjp.set(mObj);
|
||||
return JS_WrapObject(aCx, aObjp);
|
||||
}
|
||||
|
||||
|
@ -838,7 +837,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
|||
|
||||
JS::RootedObject cpows(ctx);
|
||||
if (aCpows) {
|
||||
if (!aCpows->ToObject(ctx, cpows.address())) {
|
||||
if (!aCpows->ToObject(ctx, &cpows)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ struct nsMessageListenerInfo
|
|||
class CpowHolder
|
||||
{
|
||||
public:
|
||||
virtual bool ToObject(JSContext* cx, JSObject** objp) = 0;
|
||||
virtual bool ToObject(JSContext* cx, JS::MutableHandleObject objp) = 0;
|
||||
};
|
||||
|
||||
class MOZ_STACK_CLASS SameProcessCpowHolder : public CpowHolder
|
||||
|
@ -133,7 +133,7 @@ class MOZ_STACK_CLASS SameProcessCpowHolder : public CpowHolder
|
|||
{
|
||||
}
|
||||
|
||||
bool ToObject(JSContext* aCx, JSObject** aObjp);
|
||||
bool ToObject(JSContext* aCx, JS::MutableHandleObject aObjp);
|
||||
|
||||
private:
|
||||
JS::Rooted<JSObject*> mObj;
|
||||
|
|
|
@ -72,12 +72,8 @@ GK_ATOM(align, "align")
|
|||
GK_ATOM(alink, "alink")
|
||||
GK_ATOM(all, "all")
|
||||
GK_ATOM(allowevents, "allowevents")
|
||||
GK_ATOM(allowforms, "allow-forms")
|
||||
GK_ATOM(allownegativeassertions, "allownegativeassertions")
|
||||
GK_ATOM(allowfullscreen, "allowfullscreen")
|
||||
GK_ATOM(allowsameorigin, "allow-same-origin")
|
||||
GK_ATOM(allowscripts, "allow-scripts")
|
||||
GK_ATOM(allowtopnavigation, "allow-top-navigation")
|
||||
GK_ATOM(allowuntrusted, "allowuntrusted")
|
||||
GK_ATOM(alt, "alt")
|
||||
GK_ATOM(alternate, "alternate")
|
||||
|
|
|
@ -3125,7 +3125,7 @@ nsObjectLoadingContent::LegacyCall(JSContext* aCx,
|
|||
// random cross-compartment wrappers, so we're going to have to wrap
|
||||
// everything up into our compartment, but that means we need to check that
|
||||
// this is not an Xray situation by hand.
|
||||
if (!JS_WrapObject(aCx, obj.address())) {
|
||||
if (!JS_WrapObject(aCx, &obj)) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return JS::UndefinedValue();
|
||||
}
|
||||
|
|
|
@ -13,8 +13,11 @@
|
|||
|
||||
/**
|
||||
* This flag prevents content from navigating browsing contexts other than
|
||||
* the sandboxed browsing context itself (or browsing contexts further
|
||||
* nested inside it), and the top-level browsing context.
|
||||
* itself, browsing contexts nested inside it, the top-level browsing context
|
||||
* and browsing contexts that it has opened.
|
||||
* As it is always on for sandboxed browsing contexts, it is used implicitly
|
||||
* within the code by checking that the overall flags are non-zero.
|
||||
* It is only uesd directly when the sandbox flags are initially set up.
|
||||
*/
|
||||
const unsigned long SANDBOXED_NAVIGATION = 0x1;
|
||||
|
||||
|
@ -65,4 +68,11 @@ const unsigned long SANDBOXED_POINTER_LOCK = 0x80;
|
|||
* This flag blocks the document from changing document.domain.
|
||||
*/
|
||||
const unsigned long SANDBOXED_DOMAIN = 0x100;
|
||||
|
||||
/**
|
||||
* This flag prevents content from creating new auxiliary browsing contexts,
|
||||
* e.g. using the target attribute, the window.open() method, or the
|
||||
* showModalDialog() method.
|
||||
*/
|
||||
const unsigned long SANDBOXED_AUXILIARY_NAVIGATION = 0x200;
|
||||
#endif
|
||||
|
|
|
@ -2372,6 +2372,8 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess
|
|||
return;
|
||||
}
|
||||
|
||||
RefPtr<GlyphRenderingOptions> renderingOptions = font->GetGlyphRenderingOptions();
|
||||
|
||||
GlyphBuffer buffer;
|
||||
|
||||
std::vector<Glyph> glyphBuf;
|
||||
|
@ -2443,7 +2445,8 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess
|
|||
FillGlyphs(scaledFont, buffer,
|
||||
CanvasGeneralPattern().
|
||||
ForStyle(mCtx, CanvasRenderingContext2D::STYLE_FILL, mCtx->mTarget),
|
||||
DrawOptions(mState->globalAlpha, mCtx->UsedOperation()));
|
||||
DrawOptions(mState->globalAlpha, mCtx->UsedOperation()),
|
||||
renderingOptions);
|
||||
} else if (mOp == CanvasRenderingContext2D::TEXT_DRAW_OPERATION_STROKE) {
|
||||
// stroke glyphs one at a time to avoid poor CoreGraphics performance
|
||||
// when stroking a path with a very large number of points
|
||||
|
|
|
@ -24,7 +24,7 @@ HTMLUnknownElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aScope)
|
|||
JS::Rooted<JSObject*> prototype(aCx);
|
||||
document->GetCustomPrototype(LocalName(), &prototype);
|
||||
if (prototype) {
|
||||
NS_ENSURE_TRUE(JS_WrapObject(aCx, prototype.address()), nullptr);
|
||||
NS_ENSURE_TRUE(JS_WrapObject(aCx, &prototype), nullptr);
|
||||
NS_ENSURE_TRUE(JS_SetPrototype(aCx, obj, prototype), nullptr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,13 @@ function doStuff() {
|
|||
try {
|
||||
window.parent.ok_wrapper(false, "a document contained within a sandboxed document without 'allow-same-origin' should NOT be same domain with its parent");
|
||||
} catch(e) {
|
||||
window.parent.parent.postMessage({type: "ok", ok: true, desc: "a document contained within a sandboxed document without 'allow-same-origin' should NOT be same domain with its parent"}, "*");
|
||||
}
|
||||
|
||||
try {
|
||||
window.parent.parent.ok_wrapper(false, "a document contained within a sandboxed document without 'allow-same-origin' should NOT be same domain with the top level");
|
||||
} catch(e) {
|
||||
window.parent.parent.postMessage({type: "ok", ok: true, desc: "a document contained within a sandboxed document without 'allow-same-origin' should NOT be same domain with the top level"}, "*");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
function testXHR() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open("GET", "file_iframe_sandbox_if1.html");
|
||||
xhr.open("GET", "file_iframe_sandbox_b_if1.html");
|
||||
|
||||
xhr.onreadystatechange = function (oEvent) {
|
||||
var result = false;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<title>Test for Bug 341604</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
</head>
|
||||
<script type="text/javascript">
|
||||
function ok(result, desc) {
|
||||
|
@ -13,9 +12,10 @@
|
|||
}
|
||||
|
||||
function doStuff() {
|
||||
// try to open a new window via target="_blank", window.open(), and showModalDialog()
|
||||
// try to open a new window via target="_blank", target="BC341604", window.open(), and showModalDialog()
|
||||
// the window we try to open closes itself once it opens
|
||||
sendMouseEvent({type:'click'}, 'target_blank');
|
||||
sendMouseEvent({type:'click'}, 'target_BC341604');
|
||||
|
||||
var threw = false;
|
||||
try {
|
||||
|
@ -23,7 +23,7 @@
|
|||
} catch (error) {
|
||||
threw = true;
|
||||
}
|
||||
|
||||
|
||||
ok(threw, "window.open threw a JS exception and was not allowed");
|
||||
|
||||
threw = false;
|
||||
|
@ -32,7 +32,7 @@
|
|||
} catch(error) {
|
||||
threw = true;
|
||||
}
|
||||
|
||||
|
||||
ok(threw, "window.showModalDialog threw a JS exception and was not allowed");
|
||||
}
|
||||
</script>
|
||||
|
@ -40,5 +40,6 @@
|
|||
I am sandboxed but with "allow-scripts allow-same-origin"
|
||||
|
||||
<a href="file_iframe_sandbox_open_window_fail.html" target="_blank" id="target_blank">open window</a>
|
||||
<a href="file_iframe_sandbox_open_window_fail.html" target="BC341604" id="target_BC341604">open window</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<script>
|
||||
self.close();
|
||||
</script>
|
|
@ -8,7 +8,7 @@
|
|||
</head>
|
||||
<script type="application/javascript">
|
||||
function doTest() {
|
||||
window.parent.postMessage({test:'if_10'}, "*");
|
||||
window.parent.postMessage({type: "if_10"}, "*");
|
||||
}
|
||||
</script>
|
||||
<body onload='doTest()'>
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
// Try to navigate auxiliary browsing context (window) not opened by us.
|
||||
// We should not be able to do this as we are sandboxed.
|
||||
sendMouseEvent({type:'click'}, 'navigate_window');
|
||||
window.parent.postMessage("test attempted", "*");
|
||||
window.parent.postMessage({type: "attempted"}, "*");
|
||||
|
||||
// Try to navigate auxiliary browsing context (window) not opened by us, using window.open().
|
||||
// We should not be able to do this as we are sandboxed.
|
||||
try {
|
||||
window.open("file_iframe_sandbox_window_navigation_fail.html?" + escape(test20Context), "window_to_navigate2");
|
||||
window.parent.postMessage("test attempted", "*");
|
||||
window.parent.postMessage({type: "attempted"}, "*");
|
||||
} catch(error) {
|
||||
window.parent.postMessage({ok: true, desc: test20Context + "as expected, error thrown during window.open(..., \"window_to_navigate2\")"}, "*");
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<script type="application/javascript">
|
||||
function doTest() {
|
||||
window.parent.parent.postMessage("test attempted", "*");
|
||||
window.parent.parent.postMessage({type: "attempted"}, "*");
|
||||
sendMouseEvent({type:'click'}, 'anchor');
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
function doTest() {
|
||||
try {
|
||||
window.open("file_iframe_sandbox_navigation_fail.html?" + escape(testContext), "_parent");
|
||||
window.parent.parent.postMessage("test attempted", "*");
|
||||
window.parent.parent.postMessage({type: "attempted"}, "*");
|
||||
} catch(error) {
|
||||
window.parent.parent.postMessage({ok: true, desc: testContext + "as expected, error thrown during window.open(..., \"_parent\")"}, "*");
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
function doTest() {
|
||||
try {
|
||||
window.open("file_iframe_sandbox_navigation_fail.html?" + escape(testContext), "if_parent2");
|
||||
window.parent.parent.postMessage("test attempted", "*");
|
||||
window.parent.parent.postMessage({type: "attempted"}, "*");
|
||||
} catch(error) {
|
||||
window.parent.parent.postMessage({ok: true, desc: testContext + "as expected, error thrown during window.open(..., \"if_parent2\")"}, "*");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 838692</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script type="application/javascript">
|
||||
var test27Context = "Test 27: navigate opened window by name with anchor: ";
|
||||
var test28Context = "Test 28: navigate opened window by name with window.open(): ";
|
||||
|
||||
var windowsToClose = new Array();
|
||||
|
||||
function closeWindows() {
|
||||
for (var i = 0; i < windowsToClose.length; i++) {
|
||||
windowsToClose[i].close();
|
||||
}
|
||||
}
|
||||
|
||||
// Add message listener to forward messages on to parent
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
function receiveMessage(event) {
|
||||
switch (event.data.type) {
|
||||
case "closeWindows":
|
||||
closeWindows();
|
||||
break;
|
||||
default:
|
||||
window.parent.postMessage(event.data, "*");
|
||||
}
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
try {
|
||||
windowsToClose.push(window.open("about:blank", "test27window"));
|
||||
var test27Anchor = document.getElementById("test27Anchor");
|
||||
test27Anchor.href = "file_iframe_sandbox_window_navigation_pass.html?" + escape(test27Context);
|
||||
sendMouseEvent({type:"click"}, "test27Anchor");
|
||||
window.parent.postMessage({type: "attempted"}, "*");
|
||||
} catch(error) {
|
||||
window.parent.postMessage({ok: false, desc: test27Context + "error thrown during window.open(): " + error}, "*");
|
||||
}
|
||||
|
||||
try {
|
||||
windowsToClose.push(window.open("about:blank", "test28window"));
|
||||
window.open("file_iframe_sandbox_window_navigation_pass.html?" + escape(test28Context), "test28window");
|
||||
window.parent.postMessage({type: "attempted"}, "*");
|
||||
} catch(error) {
|
||||
window.parent.postMessage({ok: false, desc: test28Context + "error thrown during window.open(): " + error}, "*");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<body onload="doTest()">
|
||||
I am sandboxed with 'allow-scripts allow-popups'
|
||||
|
||||
<a id="test27Anchor" target="test27window">Test 27 anchor</a>
|
||||
</body>
|
||||
</html>
|
|
@ -8,7 +8,7 @@
|
|||
</head>
|
||||
<script type="application/javascript">
|
||||
function doTest() {
|
||||
window.parent.parent.postMessage("test attempted", "*");
|
||||
window.parent.parent.postMessage({type: "attempted"}, "*");
|
||||
sendMouseEvent({type:'click'}, 'anchor');
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<script type="application/javascript">
|
||||
function doTest() {
|
||||
sendMouseEvent({type:'click'}, 'anchor');
|
||||
window.parent.postMessage("test attempted", "*");
|
||||
window.parent.postMessage({type: "attempted"}, "*");
|
||||
}
|
||||
</script>
|
||||
<body onload="doTest()">
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<script type="application/javascript">
|
||||
function doTest() {
|
||||
document.getElementById('anchor').href = "file_iframe_sandbox_top_navigation_fail.html" + location.search;
|
||||
window.top.opener.postMessage("test attempted", "*");
|
||||
window.top.opener.postMessage({type: "attempted"}, "*");
|
||||
sendMouseEvent({type:'click'}, 'anchor');
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<script>
|
||||
function doTest() {
|
||||
// Try to navigate top using its name (e_if7). We should not be able to do this as allow-top-navigation is not specified.
|
||||
window.top.opener.postMessage("test attempted", "*");
|
||||
window.top.opener.postMessage({type: "attempted"}, "*");
|
||||
sendMouseEvent({type:'click'}, 'navigate_top');
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Tests for Bug 766282</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
</head>
|
||||
<script type="text/javascript">
|
||||
function ok(result, desc) {
|
||||
window.parent.ok_wrapper(result, desc);
|
||||
}
|
||||
|
||||
function doStuff() {
|
||||
// Try to open a new window via target="_blank", target="BC766282" and window.open().
|
||||
// The window we try to open closes itself once it opens.
|
||||
sendMouseEvent({type:'click'}, 'target_blank');
|
||||
sendMouseEvent({type:'click'}, 'target_BC766282');
|
||||
|
||||
try {
|
||||
window.open("file_iframe_sandbox_open_window_pass.html");
|
||||
} catch(e) {
|
||||
ok(false, "Test 3: iframes sandboxed with allow-popups, should be able to open windows");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<body onLoad="doStuff()">
|
||||
I am sandboxed but with "allow-popups allow-scripts allow-same-origin"
|
||||
|
||||
<a href="file_iframe_sandbox_open_window_pass.html" target="_blank" id="target_blank">open window</a>
|
||||
<a href="file_iframe_sandbox_open_window_pass.html?BC766282" target="BC766282" id="target_BC766282">open window</a>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script type="text/javascript">
|
||||
function doStuff() {
|
||||
// Open a new window via showModalDialog().
|
||||
try {
|
||||
window.showModalDialog("file_iframe_sandbox_k_if5.html");
|
||||
} catch(e) {
|
||||
window.parent.ok_wrapper(false, "iframes sandboxed with allow-popups should be able to open a modal dialog");
|
||||
}
|
||||
|
||||
// Open a new window via showModalDialog().
|
||||
try {
|
||||
window.showModalDialog("file_iframe_sandbox_k_if7.html");
|
||||
} catch(e) {
|
||||
window.parent.ok_wrapper(false, "iframes sandboxed with allow-popups should be able to open a modal dialog");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<body onLoad="doStuff()">
|
||||
I am sandboxed with "allow-scripts allow-popups allow-same-origin allow-forms allow-top-navigation".
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script type="text/javascript">
|
||||
function doSubOpens() {
|
||||
// Open a new window showModalDialog().
|
||||
try {
|
||||
window.showModalDialog("file_iframe_sandbox_k_if9.html");
|
||||
} catch(e) {
|
||||
window.parent.ok_wrapper(false, "iframes sandboxed with allow-popups should be able to open a modal dialog");
|
||||
}
|
||||
}
|
||||
|
||||
window.doSubOpens = doSubOpens;
|
||||
</script>
|
||||
|
||||
<body>
|
||||
I am sandboxed but with "allow-scripts allow-popups allow-same-origin".
|
||||
After my initial load, "allow-same-origin" is removed and then I open file_iframe_sandbox_k_if9.html,
|
||||
which attemps to call a function in my parent.
|
||||
This should succeed since the new sandbox flags shouldn't have taken affect on me until I'm reloaded.
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Tests for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
</head>
|
||||
<script type="text/javascript">
|
||||
function ok(result, desc) {
|
||||
window.parent.ok_wrapper(result, desc);
|
||||
}
|
||||
|
||||
function doStuff() {
|
||||
// Try to open a new window via showModalDialog().
|
||||
// The window we try to open closes itself once it opens.
|
||||
try {
|
||||
window.showModalDialog("file_iframe_sandbox_open_window_pass.html");
|
||||
} catch(e) {
|
||||
ok(false, "iframes sandboxed with allow-popups should be able to open a modal dialog");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<body onLoad="doStuff()">
|
||||
I am sandboxed but with "allow-popups allow-scripts allow-same-origin"
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,47 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<script type="text/javascript">
|
||||
var windowsToClose = new Array();
|
||||
|
||||
function closeWindows() {
|
||||
for (var i = 0; i < windowsToClose.length; i++) {
|
||||
windowsToClose[i].close();
|
||||
}
|
||||
window.open("file_iframe_sandbox_close.html", "blank_if2");
|
||||
window.open("file_iframe_sandbox_close.html", "BC766282_if2");
|
||||
}
|
||||
|
||||
// Add message listener to forward messages on to parent
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
function receiveMessage(event) {
|
||||
switch (event.data.type) {
|
||||
case "closeWindows":
|
||||
closeWindows();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function doStuff() {
|
||||
// Open a new window via target="_blank", target="BC766282_if2" and window.open().
|
||||
sendMouseEvent({type:'click'}, 'target_blank_if2');
|
||||
sendMouseEvent({type:'click'}, 'target_BC766282_if2');
|
||||
|
||||
windowsToClose.push(window.open("file_iframe_sandbox_k_if2.html"));
|
||||
}
|
||||
</script>
|
||||
<body onLoad="doStuff()">
|
||||
I am navigated to from file_iframe_sandbox_k_if8.html.
|
||||
This was opened in an iframe with "allow-scripts allow-popups allow-same-origin".
|
||||
However allow-same-origin was removed from the iframe before navigating to me,
|
||||
so I should only have "allow-scripts allow-popups" in force.
|
||||
<a href="file_iframe_sandbox_k_if2.html" target="_blank" id="target_blank_if2">open window</a>
|
||||
<a href="file_iframe_sandbox_k_if2.html" target="BC766282_if2" id="target_BC766282_if2">open window</a>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script type="text/javascript">
|
||||
if (window.name == "") {
|
||||
window.name = "blank_if2";
|
||||
}
|
||||
|
||||
function ok(result, message) {
|
||||
window.opener.parent.postMessage({type: "ok", ok: result, desc: message}, "*");
|
||||
}
|
||||
|
||||
function doStuff() {
|
||||
// Check that sandboxed forms browsing context flag copied by attempting to submit a form.
|
||||
document.getElementById('a_form').submit();
|
||||
window.opener.parent.postMessage({type: "attempted"}, "*");
|
||||
|
||||
// Check that sandboxed origin browsing context flag copied by attempting to access cookies.
|
||||
try {
|
||||
var foo = document.cookie;
|
||||
ok(false, "Sandboxed origin browsing context flag NOT copied to new auxiliary browsing context.");
|
||||
} catch(error) {
|
||||
ok(true, "Sandboxed origin browsing context flag copied to new auxiliary browsing context.");
|
||||
}
|
||||
|
||||
// Check that sandboxed top-level navigation browsing context flag copied.
|
||||
// if_3 tries to navigate this document.
|
||||
var if_3 = document.getElementById('if_3');
|
||||
if_3.src = "file_iframe_sandbox_k_if3.html";
|
||||
}
|
||||
</script>
|
||||
|
||||
<body onLoad="doStuff()">
|
||||
I am not sandboxed directly, but opened from a sandboxed document with 'allow-scripts allow-popups'
|
||||
|
||||
<form method="get" action="file_iframe_sandbox_window_form_fail.html" id="a_form">
|
||||
First name: <input type="text" name="firstname">
|
||||
Last name: <input type="text" name="lastname">
|
||||
<input type="submit" id="a_button">
|
||||
</form>
|
||||
|
||||
<iframe id="if_3" src="about:blank" height="10" width="10"></iframe>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
</head>
|
||||
<script type="application/javascript">
|
||||
function doTest() {
|
||||
sendMouseEvent({type:'click'}, 'anchor');
|
||||
window.parent.opener.parent.postMessage({type: "attempted"}, "*");
|
||||
}
|
||||
</script>
|
||||
<body onload="doTest()">
|
||||
I am sandboxed with 'allow-scripts allow-popups'
|
||||
|
||||
<a href="file_iframe_sandbox_window_top_navigation_fail.html" target='_top' id='anchor'>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script type="text/javascript">
|
||||
function doStuff() {
|
||||
// Open a new window via target="_blank", target="BC766282_if5" and window.open().
|
||||
sendMouseEvent({type:'click'}, 'target_blank_if5');
|
||||
sendMouseEvent({type:'click'}, 'target_BC766282_if5');
|
||||
|
||||
window.open("file_iframe_sandbox_k_if5.html");
|
||||
|
||||
// Open a new window via target="_blank", target="BC766282_if7" and window.open().
|
||||
sendMouseEvent({type:'click'}, 'target_blank_if7');
|
||||
sendMouseEvent({type:'click'}, 'target_BC766282_if7');
|
||||
|
||||
window.open("file_iframe_sandbox_k_if7.html");
|
||||
}
|
||||
</script>
|
||||
|
||||
<body onLoad="doStuff()">
|
||||
I am sandboxed with "allow-scripts allow-popups allow-same-origin allow-forms allow-top-navigation".
|
||||
<a href="file_iframe_sandbox_k_if5.html" target="_blank" id="target_blank_if5">open window</a>
|
||||
<a href="file_iframe_sandbox_k_if5.html" target="BC766282_if5" id="target_BC766282_if5">open window</a>
|
||||
|
||||
<a href="file_iframe_sandbox_k_if7.html" target="_blank" id="target_blank_if7">open window</a>
|
||||
<a href="file_iframe_sandbox_k_if7.html" target="BC766282_if7" id="target_BC766282_if7">open window</a>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script type="text/javascript">
|
||||
function doStuff() {
|
||||
// Check that sandboxed origin browsing context flag NOT set by attempting to access cookies.
|
||||
try {
|
||||
var foo = document.cookie;
|
||||
window.opener.parent.ok_wrapper(true, "Sandboxed origin browsing context flag NOT set on new auxiliary browsing context.");
|
||||
} catch(error) {
|
||||
window.opener.parent.ok_wrapper(false, "Sandboxed origin browsing context flag set on new auxiliary browsing context.");
|
||||
}
|
||||
|
||||
// Check that sandboxed top-level navigation browsing context flag NOT set.
|
||||
// if_6 tries to navigate this document.
|
||||
var if_6 = document.getElementById('if_6');
|
||||
if_6.src = "file_iframe_sandbox_k_if6.html";
|
||||
}
|
||||
</script>
|
||||
|
||||
<body onLoad="doStuff()">
|
||||
I am not sandboxed directly, but opened from a sandboxed document with at least
|
||||
'allow-scripts allow-popups allow-same-origin allow-top-navigation'
|
||||
|
||||
<iframe id="if_6" src="about:blank" height="10" width="10"></iframe>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
</head>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest() {
|
||||
sendMouseEvent({type:'click'}, 'anchor');
|
||||
}
|
||||
</script>
|
||||
|
||||
<body onload="doTest()">
|
||||
I am sandboxed with at least 'allow-scripts allow-popups allow-top-navigation'
|
||||
|
||||
<a href="file_iframe_sandbox_window_top_navigation_pass.html" target='_top' id='anchor'>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script type="text/javascript">
|
||||
function doStuff() {
|
||||
// Check that sandboxed forms browsing context flag NOT set by attempting to submit a form.
|
||||
document.getElementById('a_form').submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
<body onLoad="doStuff()">
|
||||
I am not sandboxed directly, but opened from a sandboxed document with at least
|
||||
'allow-scripts allow-popups allow-forms allow-same-origin'
|
||||
|
||||
<form method="get" action="file_iframe_sandbox_window_form_pass.html" id="a_form">
|
||||
First name: <input type="text" name="firstname">
|
||||
Last name: <input type="text" name="lastname">
|
||||
<input type="submit" id="a_button">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script type="text/javascript">
|
||||
function doSubOpens() {
|
||||
// Open a new window via target="_blank", target="BC766282_if9" and window.open().
|
||||
sendMouseEvent({type:'click'}, 'target_blank_if9');
|
||||
sendMouseEvent({type:'click'}, 'target_BC766282_if9');
|
||||
|
||||
window.open("file_iframe_sandbox_k_if9.html");
|
||||
|
||||
sendMouseEvent({type:'click'}, 'target_if1');
|
||||
}
|
||||
|
||||
window.doSubOpens = doSubOpens;
|
||||
</script>
|
||||
|
||||
<body>
|
||||
I am sandboxed but with "allow-scripts allow-popups allow-same-origin".
|
||||
After my initial load, "allow-same-origin" is removed and then I open file_iframe_sandbox_k_if9.html
|
||||
in 3 different ways, which attemps to call a function in my parent.
|
||||
This should succeed since the new sandbox flags shouldn't have taken affect on me until I'm reloaded.
|
||||
<a href="file_iframe_sandbox_k_if9.html" target="_blank" id="target_blank_if9">open window</a>
|
||||
<a href="file_iframe_sandbox_k_if9.html" target="BC766282_if9" id="target_BC766282_if9">open window</a>
|
||||
|
||||
Now navigate to file_iframe_sandbox_k_if1.html to do tests for a sandbox opening a window
|
||||
when only "allow-scripts allow-popups" are specified.
|
||||
<a href="file_iframe_sandbox_k_if1.html" id="target_if1">navigate to if1</a>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
function doStuff() {
|
||||
window.opener.parent.ok_wrapper(true, "A window opened from within a sandboxed document should inherit the flags of the document, not of the docshell/sandbox attribute.");
|
||||
self.close();
|
||||
}
|
||||
</script>
|
||||
|
||||
<body onload='doStuff()'>
|
||||
I'm a window opened from the sandboxed document of file_iframe_sandbox_k_if8.html.
|
||||
I should be able to call ok_wrapper in main test page directly because I should be same-origin with it.
|
||||
</body>
|
||||
</html>
|
|
@ -3,7 +3,6 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 341604</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
|
@ -14,8 +13,7 @@
|
|||
|
||||
<script>
|
||||
function doStuff() {
|
||||
console.log("file_iframe_sandbox_window_open_fail.html");
|
||||
window.opener.ok(false, "sandboxed documents should NOT be able to open windows");
|
||||
self.close();
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<body onLoad="doStuff()">
|
||||
I should be opened by a sandboxed iframe via any method when "allow-popups" is specified.
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<script>
|
||||
function doStuff() {
|
||||
// Check that the browsing context's (window's) name is as expected.
|
||||
var expectedName = location.search.substring(1);
|
||||
if (expectedName == window.name) {
|
||||
window.opener.ok(true, "sandboxed documents should be able to open windows when \"allow-popups\" is specified");
|
||||
} else {
|
||||
window.opener.ok(false, "window opened with \"allow-popups\", but expected name was " + expectedName + " and actual was " + window.name);
|
||||
}
|
||||
self.close();
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<body onLoad="doStuff()">
|
||||
I should NOT be loaded by a form submit from a window opened from a sandbox without 'allow-forms'.
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<script>
|
||||
function doStuff() {
|
||||
window.opener.parent.postMessage({ok: false, desc: "documents sandboxed without allow-forms should NOT be able to submit forms"}, "*");
|
||||
|
||||
self.close();
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
function doStuff() {
|
||||
window.opener.parent.ok_wrapper(true, "Sandboxed forms browsing context flag NOT set on new auxiliary browsing context.");
|
||||
|
||||
self.close();
|
||||
}
|
||||
</script>
|
||||
|
||||
<body onLoad="doStuff()">
|
||||
I should be loaded by a form submit from a window opened from a sandbox with 'allow-forms allow-same-origin'.
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
function doStuff() {
|
||||
var testContext = unescape(location.search.substring(1));
|
||||
window.opener.postMessage({type: "ok", ok: true, desc: testContext + "a permitted sandboxed document should be able to navigate a window it has opened.", addToAttempted: false}, "*");
|
||||
window.close();
|
||||
}
|
||||
</script>
|
||||
|
||||
<body onLoad="doStuff()">
|
||||
PASS
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<script>
|
||||
function doStuff() {
|
||||
window.opener.parent.postMessage({ok: false, desc: "Sandboxed top-level navigation browsing context flag NOT copied to new auxiliary browsing context."}, "*");
|
||||
|
||||
// Check that when no browsing context returned by "target='_top'", a new browsing context isn't opened by mistake.
|
||||
try {
|
||||
window.opener.parent.opener.parent.postMessage({ok: false, desc: "An attempt at top navigation without 'allow-top-navigation' should not have opened a new browsing context."}, "*");
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
self.close();
|
||||
}
|
||||
</script>
|
||||
<body onLoad="doStuff()">
|
||||
FAIL
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 766282</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
function doStuff() {
|
||||
window.opener.parent.ok_wrapper(true, "Sandboxed top-level navigation browsing context flag NOT copied to new auxiliary browsing context.");
|
||||
|
||||
self.close();
|
||||
}
|
||||
</script>
|
||||
|
||||
<body onLoad="doStuff()">
|
||||
I am navigated to from a window opened from a sandbox with allow-top-navigation.
|
||||
</body>
|
||||
</html>
|
|
@ -69,6 +69,7 @@ support-files =
|
|||
file_iframe_sandbox_c_if6.html
|
||||
file_iframe_sandbox_c_if7.html
|
||||
file_iframe_sandbox_c_if8.html
|
||||
file_iframe_sandbox_close.html
|
||||
file_iframe_sandbox_d_if1.html
|
||||
file_iframe_sandbox_d_if10.html
|
||||
file_iframe_sandbox_d_if11.html
|
||||
|
@ -84,6 +85,7 @@ support-files =
|
|||
file_iframe_sandbox_d_if20.html
|
||||
file_iframe_sandbox_d_if21.html
|
||||
file_iframe_sandbox_d_if22.html
|
||||
file_iframe_sandbox_d_if23.html
|
||||
file_iframe_sandbox_d_if3.html
|
||||
file_iframe_sandbox_d_if4.html
|
||||
file_iframe_sandbox_d_if5.html
|
||||
|
@ -114,14 +116,33 @@ support-files =
|
|||
file_iframe_sandbox_form_fail.html
|
||||
file_iframe_sandbox_form_pass.html
|
||||
file_iframe_sandbox_g_if1.html
|
||||
file_iframe_sandbox_h_if1.html
|
||||
file_iframe_sandbox_j_if1.html
|
||||
file_iframe_sandbox_j_if2.html
|
||||
file_iframe_sandbox_j_if3.html
|
||||
file_iframe_sandbox_k_if1.html
|
||||
file_iframe_sandbox_k_if2.html
|
||||
file_iframe_sandbox_k_if3.html
|
||||
file_iframe_sandbox_k_if4.html
|
||||
file_iframe_sandbox_k_if5.html
|
||||
file_iframe_sandbox_k_if6.html
|
||||
file_iframe_sandbox_k_if7.html
|
||||
file_iframe_sandbox_k_if8.html
|
||||
file_iframe_sandbox_k_if9.html
|
||||
file_iframe_sandbox_navigation_fail.html
|
||||
file_iframe_sandbox_navigation_pass.html
|
||||
file_iframe_sandbox_navigation_start.html
|
||||
file_iframe_sandbox_open_window_fail.html
|
||||
file_iframe_sandbox_open_window_pass.html
|
||||
file_iframe_sandbox_pass.js
|
||||
file_iframe_sandbox_top_navigation_fail.html
|
||||
file_iframe_sandbox_top_navigation_pass.html
|
||||
file_iframe_sandbox_window_form_fail.html
|
||||
file_iframe_sandbox_window_form_pass.html
|
||||
file_iframe_sandbox_window_navigation_fail.html
|
||||
file_iframe_sandbox_window_navigation_pass.html
|
||||
file_iframe_sandbox_window_top_navigation_pass.html
|
||||
file_iframe_sandbox_window_top_navigation_fail.html
|
||||
file_iframe_sandbox_worker.js
|
||||
file_srcdoc-2.html
|
||||
file_srcdoc.html
|
||||
|
@ -361,9 +382,12 @@ support-files =
|
|||
[test_htmlcollection.html]
|
||||
[test_iframe_sandbox_general.html]
|
||||
[test_iframe_sandbox_inheritance.html]
|
||||
[test_iframe_sandbox_modal.html]
|
||||
[test_iframe_sandbox_navigation.html]
|
||||
[test_iframe_sandbox_navigation2.html]
|
||||
[test_iframe_sandbox_plugins.html]
|
||||
[test_iframe_sandbox_popups.html]
|
||||
[test_iframe_sandbox_popups_inheritance.html]
|
||||
[test_iframe_sandbox_same_origin.html]
|
||||
[test_iframe_sandbox_workers.html]
|
||||
[test_img_attributes_reflection.html]
|
||||
|
|
|
@ -1,234 +1,239 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=341604
|
||||
Implement HTML5 sandbox attribute for IFRAMEs - general tests
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 341604</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.expectAssertions(1);
|
||||
|
||||
/** Test for Bug 341604 - Implement HTML5 sandbox attribute for IFRAMEs - general tests **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// a postMessage handler that is used by sandboxed iframes without
|
||||
// 'allow-same-origin' to communicate pass/fail back to this main page.
|
||||
// it expects to be called with an object like {ok: true/false, desc:
|
||||
// <description of the test> which it then forwards to ok()
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
function receiveMessage(event)
|
||||
{
|
||||
ok_wrapper(event.data.ok, event.data.desc);
|
||||
}
|
||||
|
||||
var completedTests = 0;
|
||||
var passedTests = 0;
|
||||
|
||||
function ok_wrapper(result, desc) {
|
||||
ok(result, desc);
|
||||
|
||||
completedTests++;
|
||||
|
||||
if (result) {
|
||||
passedTests++;
|
||||
}
|
||||
|
||||
if (completedTests == 23) {
|
||||
is(passedTests, 23, "There are 23 general tests that should pass");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
// passes if good
|
||||
// 1) test that inline scripts (<script>) can run in an iframe sandboxed with "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if1.html which has 'allow-scripts')
|
||||
|
||||
// passes if good
|
||||
// 2) test that <script src=...> can run in an iframe sandboxed with "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if1.html which has 'allow-scripts')
|
||||
|
||||
// passes if good
|
||||
// 3) test that script in an event listener (body onload) can run in an iframe sandboxed with "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if1.html which has 'allow-scripts')
|
||||
|
||||
// passes if good
|
||||
// 4) test that script in an javascript:url can run in an iframe sandboxed with "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if1.html which has 'allow-scripts')
|
||||
|
||||
// fails if bad
|
||||
// 5) test that inline scripts cannot run in an iframe sandboxed without "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if2.html which has sandbox='')
|
||||
|
||||
// fails if bad
|
||||
// 6) test that <script src=...> cannot run in an iframe sandboxed without "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if2.html which has sandbox='')
|
||||
|
||||
// fails if bad
|
||||
// 7) test that script in an event listener (body onload) cannot run in an iframe sandboxed without "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if2.html which has sandbox='')
|
||||
|
||||
// fails if bad
|
||||
// 8) test that script in an event listener (img onerror) cannot run in an iframe sandboxed without "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if2.html which has sandbox='')
|
||||
|
||||
// fails if bad
|
||||
// 9) test that script in an javascript:url cannot run in an iframe sandboxed without "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if_5.html which has sandbox='allow-same-origin')
|
||||
var if_w = document.getElementById('if_5').contentWindow;
|
||||
sendMouseEvent({type:'click'}, 'a_link', if_w);
|
||||
|
||||
// passes if good
|
||||
// 10) test that a new iframe has sandbox attribute
|
||||
var ifr = document.createElement("iframe");
|
||||
ok_wrapper("sandbox" in ifr, "a new iframe should have a sandbox attribute");
|
||||
|
||||
// passes if good
|
||||
// 11) test that the sandbox attribute's default value is an empty string
|
||||
ok_wrapper(ifr.sandbox === "", "default sandbox attribute should be an empty string");
|
||||
|
||||
// passes if good
|
||||
// 12) test that a sandboxed iframe with 'allow-forms' can submit forms
|
||||
// (done in file_iframe_sandbox_c_if3.html which has 'allow-forms' and 'allow-scripts')
|
||||
|
||||
// fails if bad
|
||||
// 13) test that a sandboxed iframe without 'allow-forms' can NOT submit forms
|
||||
// (done in file_iframe_sandbox_c_if1.html which only has 'allow-scripts')
|
||||
|
||||
// fails if bad
|
||||
// 14) test that a sandboxed iframe can't open a new window using the target.attribute
|
||||
// this is done via file_iframe_sandbox_c_if4.html which is sandboxed with "allow-scripts" and "allow-same-origin"
|
||||
// the window it attempts to open calls window.opener.ok(false, ...) and file_iframe_c_if4.html has an ok()
|
||||
// function that calls window.parent.ok_wrapper
|
||||
|
||||
// passes if good
|
||||
// 15) test that a sandboxed iframe can't open a new window using window.open
|
||||
// this is done via file_iframe_sandbox_c_if4.html which is sandboxed with "allow-scripts" and "allow-same-origin"
|
||||
// the window it attempts to open calls window.opener.ok(false, ...) and file_iframe_c_if4.html has an ok()
|
||||
// function that calls window.parent.ok_wrapper
|
||||
|
||||
// passes if good
|
||||
// 16) test that a sandboxed iframe can't open a new window using window.ShowModalDialog
|
||||
// this is done via file_iframe_sandbox_c_if4.html which is sandboxed with "allow-scripts" and "allow-same-origin"
|
||||
// the window it attempts to open calls window.opener.ok(false, ...) and file_iframe_c_if4.html has an ok()
|
||||
// function that calls window.parent.ok_wrapper
|
||||
|
||||
// passes twice if good
|
||||
// 17) test that a sandboxed iframe can access same-origin documents and run scripts when its sandbox attribute
|
||||
// is separated with two spaces
|
||||
// done via file_iframe_sandbox_c_if6.html which is sandboxed with " allow-scripts allow-same-origin "
|
||||
|
||||
// passes twice if good
|
||||
// 18) test that a sandboxed iframe can access same-origin documents and run scripts when its sandbox attribute
|
||||
// is separated with tabs
|
||||
// done via file_iframe_sandbox_c_if6.html which is sandboxed with "	allow-scripts	allow-same-origin	"
|
||||
|
||||
// passes twice if good
|
||||
// 19) test that a sandboxed iframe can access same-origin documents and run scripts when its sandbox attribute
|
||||
// is separated with line feeds
|
||||
// done via file_iframe_sandbox_c_if6.html which is sandboxed with "
allow-scripts
allow-same-origin
"
|
||||
|
||||
// passes twice if good
|
||||
// 20) test that a sandboxed iframe can access same-origin documents and run scripts when its sandbox attribute
|
||||
// is separated with form feeds
|
||||
// done via file_iframe_sandbox_c_if6.html which is sandboxed with "allow-scriptsallow-same-origin"
|
||||
|
||||
// passes twice if good
|
||||
// 21) test that a sandboxed iframe can access same-origin documents and run scripts when its sandbox attribute
|
||||
// is separated with carriage returns
|
||||
// done via file_iframe_sandbox_c_if6.html which is sandboxed with "
allow-scripts
allow-same-origin
"
|
||||
|
||||
// fails if bad
|
||||
// 22) test that an iframe with sandbox="" does NOT have script in a src attribute created by a javascript:
|
||||
// URL executed
|
||||
// done by this page, see if_7
|
||||
|
||||
// passes if good
|
||||
// 23) test that an iframe with sandbox="allow-scripts" DOES have script in a src attribute created by a javascript:
|
||||
// URL executed
|
||||
// done by this page, see if_8
|
||||
|
||||
// fails if bad
|
||||
// 24) test that an iframe with sandbox="", starting out with a document already loaded, does NOT have script in a newly
|
||||
// set src attribute created by a javascript: URL executed
|
||||
// done by this page, see if_9
|
||||
|
||||
// passes if good
|
||||
// 25) test that an iframe with sandbox="allow-scripts", starting out with a document already loaded, DOES have script
|
||||
// in a newly set src attribute created by a javascript: URL executed
|
||||
// done by this page, see if_10
|
||||
|
||||
// passes if good or fails if bad
|
||||
// 26) test that an sandboxed document without 'allow-same-origin' can NOT access indexedDB
|
||||
// done via file_iframe_sandbox_c_if7.html, which has sandbox='allow-scripts'
|
||||
|
||||
// passes if good or fails if bad
|
||||
// 26) test that an sandboxed document without 'allow-same-origin' can access indexedDB
|
||||
// done via file_iframe_sandbox_c_if8.html, which has sandbox='allow-scripts allow-same-origin'
|
||||
}
|
||||
|
||||
addLoadEvent(doTest);
|
||||
|
||||
var started_if_9 = false;
|
||||
var started_if_10 = false;
|
||||
|
||||
function start_if_9() {
|
||||
if (started_if_9)
|
||||
return;
|
||||
|
||||
started_if_9 = true;
|
||||
sendMouseEvent({type:'click'}, 'a_button');
|
||||
}
|
||||
|
||||
function start_if_10() {
|
||||
if (started_if_10)
|
||||
return;
|
||||
|
||||
started_if_10 = true;
|
||||
sendMouseEvent({type:'click'}, 'a_button2');
|
||||
}
|
||||
|
||||
function do_if_9() {
|
||||
var if_9 = document.getElementById('if_9');
|
||||
if_9.src = 'javascript:"<html><script>window.parent.ok_wrapper(false, \'an iframe sandboxed without allow-scripts should not execute script in a javascript URL in a newly set src attribute\');<\/script><\/html>"';
|
||||
}
|
||||
|
||||
function do_if_10() {
|
||||
var if_10 = document.getElementById('if_10');
|
||||
if_10.src = 'javascript:"<html><script>window.parent.ok_wrapper(true, \'an iframe sandboxed with allow-scripts should execute script in a javascript URL in a newly set src attribute\');<\/script><\/html>"';
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=341604">Mozilla Bug 341604</a> - Implement HTML5 sandbox attribute for IFRAMEs
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<iframe sandbox="allow-same-origin allow-scripts" id="if_1" src="file_iframe_sandbox_c_if1.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="" id="if_2" src="file_iframe_sandbox_c_if2.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-forms allow-scripts" id="if_3" src="file_iframe_sandbox_c_if3.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin allow-scripts" id="if_4" src="file_iframe_sandbox_c_if4.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin" id="if_5" src="file_iframe_sandbox_c_if5.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox=" allow-same-origin allow-scripts " id="if_6_a" src="file_iframe_sandbox_c_if6.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="	allow-same-origin	allow-scripts	" id="if_6_b" src="file_iframe_sandbox_c_if6.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="
allow-same-origin
allow-scripts
" id="if_6_c" src="file_iframe_sandbox_c_if6.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-originallow-scripts" id="if_6_d" src="file_iframe_sandbox_c_if6.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="
allow-same-origin
allow-scripts
" id="if_6_e" src="file_iframe_sandbox_c_if6.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin" id='if_7' src="javascript:'<html><script>window.parent.ok_wrapper(false, \'an iframe sandboxed without allow-scripts should not execute script in a javascript URL in its src attribute\');<\/script><\/html>';" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin allow-scripts" id='if_8' src="javascript:'<html><script>window.parent.ok_wrapper(true, \'an iframe sandboxed without allow-scripts should execute script in a javascript URL in its src attribute\');<\/script><\/html>';" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin" onload='start_if_9()' id='if_9' src="about:blank" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin allow-scripts" onload='start_if_10()' id='if_10' src="about:blank" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts" id='if_11' src="file_iframe_sandbox_c_if7.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin allow-scripts" id='if_12' src="file_iframe_sandbox_c_if8.html" height="10" width="10"></iframe>
|
||||
<input type='button' id="a_button" onclick='do_if_9()'>
|
||||
<input type='button' id="a_button2" onclick='do_if_10()'>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=341604
|
||||
Implement HTML5 sandbox attribute for IFRAMEs - general tests
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Tests for Bug 341604 and Bug 766282</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<script type="application/javascript">
|
||||
/** Test for Bug 341604 - Implement HTML5 sandbox attribute for IFRAMEs - general tests **/
|
||||
|
||||
SimpleTest.expectAssertions(0, 1);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// a postMessage handler that is used by sandboxed iframes without
|
||||
// 'allow-same-origin' to communicate pass/fail back to this main page.
|
||||
// it expects to be called with an object like {ok: true/false, desc:
|
||||
// <description of the test> which it then forwards to ok()
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
function receiveMessage(event)
|
||||
{
|
||||
ok_wrapper(event.data.ok, event.data.desc);
|
||||
}
|
||||
|
||||
var completedTests = 0;
|
||||
var passedTests = 0;
|
||||
|
||||
function ok_wrapper(result, desc) {
|
||||
ok(result, desc);
|
||||
|
||||
completedTests++;
|
||||
|
||||
if (result) {
|
||||
passedTests++;
|
||||
}
|
||||
|
||||
if (completedTests == 23) {
|
||||
is(passedTests, completedTests, "There are " + completedTests + " general tests that should pass");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
// passes if good
|
||||
// 1) test that inline scripts (<script>) can run in an iframe sandboxed with "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if1.html which has 'allow-scripts')
|
||||
|
||||
// passes if good
|
||||
// 2) test that <script src=...> can run in an iframe sandboxed with "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if1.html which has 'allow-scripts')
|
||||
|
||||
// passes if good
|
||||
// 3) test that script in an event listener (body onload) can run in an iframe sandboxed with "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if1.html which has 'allow-scripts')
|
||||
|
||||
// passes if good
|
||||
// 4) test that script in an javascript:url can run in an iframe sandboxed with "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if1.html which has 'allow-scripts')
|
||||
|
||||
// fails if bad
|
||||
// 5) test that inline scripts cannot run in an iframe sandboxed without "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if2.html which has sandbox='')
|
||||
|
||||
// fails if bad
|
||||
// 6) test that <script src=...> cannot run in an iframe sandboxed without "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if2.html which has sandbox='')
|
||||
|
||||
// fails if bad
|
||||
// 7) test that script in an event listener (body onload) cannot run in an iframe sandboxed without "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if2.html which has sandbox='')
|
||||
|
||||
// fails if bad
|
||||
// 8) test that script in an event listener (img onerror) cannot run in an iframe sandboxed without "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if2.html which has sandbox='')
|
||||
|
||||
// fails if bad
|
||||
// 9) test that script in an javascript:url cannot run in an iframe sandboxed without "allow-scripts"
|
||||
// (done in file_iframe_sandbox_c_if_5.html which has sandbox='allow-same-origin')
|
||||
var if_w = document.getElementById('if_5').contentWindow;
|
||||
sendMouseEvent({type:'click'}, 'a_link', if_w);
|
||||
|
||||
// passes if good
|
||||
// 10) test that a new iframe has sandbox attribute
|
||||
var ifr = document.createElement("iframe");
|
||||
ok_wrapper("sandbox" in ifr, "a new iframe should have a sandbox attribute");
|
||||
|
||||
// passes if good
|
||||
// 11) test that the sandbox attribute's default value is an empty string
|
||||
ok_wrapper(ifr.sandbox === "", "default sandbox attribute should be an empty string");
|
||||
|
||||
// passes if good
|
||||
// 12) test that a sandboxed iframe with 'allow-forms' can submit forms
|
||||
// (done in file_iframe_sandbox_c_if3.html which has 'allow-forms' and 'allow-scripts')
|
||||
|
||||
// fails if bad
|
||||
// 13) test that a sandboxed iframe without 'allow-forms' can NOT submit forms
|
||||
// (done in file_iframe_sandbox_c_if1.html which only has 'allow-scripts')
|
||||
|
||||
// fails if bad
|
||||
// 14) test that a sandboxed iframe can't open a new window using the target.attribute
|
||||
// this is done via file_iframe_sandbox_c_if4.html which is sandboxed with "allow-scripts" and "allow-same-origin"
|
||||
// the window it attempts to open calls window.opener.ok(false, ...) and file_iframe_c_if4.html has an ok()
|
||||
// function that calls window.parent.ok_wrapper
|
||||
|
||||
// passes if good
|
||||
// 15) test that a sandboxed iframe can't open a new window using window.open
|
||||
// this is done via file_iframe_sandbox_c_if4.html which is sandboxed with "allow-scripts" and "allow-same-origin"
|
||||
// the window it attempts to open calls window.opener.ok(false, ...) and file_iframe_c_if4.html has an ok()
|
||||
// function that calls window.parent.ok_wrapper
|
||||
|
||||
// passes if good
|
||||
// 16) test that a sandboxed iframe can't open a new window using window.ShowModalDialog
|
||||
// this is done via file_iframe_sandbox_c_if4.html which is sandboxed with "allow-scripts" and "allow-same-origin"
|
||||
// the window it attempts to open calls window.opener.ok(false, ...) and file_iframe_c_if4.html has an ok()
|
||||
// function that calls window.parent.ok_wrapper
|
||||
|
||||
// passes twice if good
|
||||
// 17) test that a sandboxed iframe can access same-origin documents and run scripts when its sandbox attribute
|
||||
// is separated with two spaces
|
||||
// done via file_iframe_sandbox_c_if6.html which is sandboxed with " allow-scripts allow-same-origin "
|
||||
|
||||
// passes twice if good
|
||||
// 18) test that a sandboxed iframe can access same-origin documents and run scripts when its sandbox attribute
|
||||
// is separated with tabs
|
||||
// done via file_iframe_sandbox_c_if6.html which is sandboxed with "	allow-scripts	allow-same-origin	"
|
||||
|
||||
// passes twice if good
|
||||
// 19) test that a sandboxed iframe can access same-origin documents and run scripts when its sandbox attribute
|
||||
// is separated with line feeds
|
||||
// done via file_iframe_sandbox_c_if6.html which is sandboxed with "
allow-scripts
allow-same-origin
"
|
||||
|
||||
// passes twice if good
|
||||
// 20) test that a sandboxed iframe can access same-origin documents and run scripts when its sandbox attribute
|
||||
// is separated with form feeds
|
||||
// done via file_iframe_sandbox_c_if6.html which is sandboxed with "allow-scriptsallow-same-origin"
|
||||
|
||||
// passes twice if good
|
||||
// 21) test that a sandboxed iframe can access same-origin documents and run scripts when its sandbox attribute
|
||||
// is separated with carriage returns
|
||||
// done via file_iframe_sandbox_c_if6.html which is sandboxed with "
allow-scripts
allow-same-origin
"
|
||||
|
||||
// fails if bad
|
||||
// 22) test that an iframe with sandbox="" does NOT have script in a src attribute created by a javascript:
|
||||
// URL executed
|
||||
// done by this page, see if_7
|
||||
|
||||
// passes if good
|
||||
// 23) test that an iframe with sandbox="allow-scripts" DOES have script in a src attribute created by a javascript:
|
||||
// URL executed
|
||||
// done by this page, see if_8
|
||||
|
||||
// fails if bad
|
||||
// 24) test that an iframe with sandbox="", starting out with a document already loaded, does NOT have script in a newly
|
||||
// set src attribute created by a javascript: URL executed
|
||||
// done by this page, see if_9
|
||||
|
||||
// passes if good
|
||||
// 25) test that an iframe with sandbox="allow-scripts", starting out with a document already loaded, DOES have script
|
||||
// in a newly set src attribute created by a javascript: URL executed
|
||||
// done by this page, see if_10
|
||||
|
||||
// passes if good or fails if bad
|
||||
// 26) test that an sandboxed document without 'allow-same-origin' can NOT access indexedDB
|
||||
// done via file_iframe_sandbox_c_if7.html, which has sandbox='allow-scripts'
|
||||
|
||||
// passes if good or fails if bad
|
||||
// 27) test that an sandboxed document with 'allow-same-origin' can access indexedDB
|
||||
// done via file_iframe_sandbox_c_if8.html, which has sandbox='allow-scripts allow-same-origin'
|
||||
|
||||
// fails if bad
|
||||
// 28) Test that a sandboxed iframe can't open a new window using the target.attribute for a
|
||||
// non-existing browsing context (BC341604).
|
||||
// This is done via file_iframe_sandbox_c_if4.html which is sandboxed with "allow-scripts" and "allow-same-origin"
|
||||
// the window it attempts to open calls window.opener.ok(false, ...) and file_iframe_c_if4.html has an ok()
|
||||
// function that calls window.parent.ok_wrapper.
|
||||
}
|
||||
|
||||
addLoadEvent(doTest);
|
||||
|
||||
var started_if_9 = false;
|
||||
var started_if_10 = false;
|
||||
|
||||
function start_if_9() {
|
||||
if (started_if_9)
|
||||
return;
|
||||
|
||||
started_if_9 = true;
|
||||
sendMouseEvent({type:'click'}, 'a_button');
|
||||
}
|
||||
|
||||
function start_if_10() {
|
||||
if (started_if_10)
|
||||
return;
|
||||
|
||||
started_if_10 = true;
|
||||
sendMouseEvent({type:'click'}, 'a_button2');
|
||||
}
|
||||
|
||||
function do_if_9() {
|
||||
var if_9 = document.getElementById('if_9');
|
||||
if_9.src = 'javascript:"<html><script>window.parent.ok_wrapper(false, \'an iframe sandboxed without allow-scripts should not execute script in a javascript URL in a newly set src attribute\');<\/script><\/html>"';
|
||||
}
|
||||
|
||||
function do_if_10() {
|
||||
var if_10 = document.getElementById('if_10');
|
||||
if_10.src = 'javascript:"<html><script>window.parent.ok_wrapper(true, \'an iframe sandboxed with allow-scripts should execute script in a javascript URL in a newly set src attribute\');<\/script><\/html>"';
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=341604">Mozilla Bug 341604</a> - Implement HTML5 sandbox attribute for IFRAMEs
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<iframe sandbox="allow-same-origin allow-scripts" id="if_1" src="file_iframe_sandbox_c_if1.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="" id="if_2" src="file_iframe_sandbox_c_if2.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-forms allow-scripts" id="if_3" src="file_iframe_sandbox_c_if3.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin allow-scripts" id="if_4" src="file_iframe_sandbox_c_if4.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin" id="if_5" src="file_iframe_sandbox_c_if5.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox=" allow-same-origin allow-scripts " id="if_6_a" src="file_iframe_sandbox_c_if6.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="	allow-same-origin	allow-scripts	" id="if_6_b" src="file_iframe_sandbox_c_if6.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="
allow-same-origin
allow-scripts
" id="if_6_c" src="file_iframe_sandbox_c_if6.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-originallow-scripts" id="if_6_d" src="file_iframe_sandbox_c_if6.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="
allow-same-origin
allow-scripts
" id="if_6_e" src="file_iframe_sandbox_c_if6.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin" id='if_7' src="javascript:'<html><script>window.parent.ok_wrapper(false, \'an iframe sandboxed without allow-scripts should not execute script in a javascript URL in its src attribute\');<\/script><\/html>';" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin allow-scripts" id='if_8' src="javascript:'<html><script>window.parent.ok_wrapper(true, \'an iframe sandboxed without allow-scripts should execute script in a javascript URL in its src attribute\');<\/script><\/html>';" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin" onload='start_if_9()' id='if_9' src="about:blank" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin allow-scripts" onload='start_if_10()' id='if_10' src="about:blank" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts" id='if_11' src="file_iframe_sandbox_c_if7.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin allow-scripts" id='if_12' src="file_iframe_sandbox_c_if8.html" height="10" width="10"></iframe>
|
||||
<input type='button' id="a_button" onclick='do_if_9()'>
|
||||
<input type='button' id="a_button2" onclick='do_if_10()'>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,168 +1,205 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=341604
|
||||
Implement HTML5 sandbox attribute for IFRAMEs - inheritance tests
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 341604</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<script type="application/javascript">
|
||||
/** Test for Bug 341604 - Implement HTML5 sandbox attribute for IFRAMEs **/
|
||||
/** Inheritance Tests **/
|
||||
|
||||
// Assertion failure in docshell/shistory/src/nsSHEntry.cpp (currently line 625).
|
||||
// Bug 901876 raised.
|
||||
SimpleTest.expectAssertions(1);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// A postMessage handler that is used by sandboxed iframes without
|
||||
// 'allow-same-origin' to communicate pass/fail back to this main page.
|
||||
// It expects to be called with an object like {ok: true/false, desc:
|
||||
// <description of the test> which it then forwards to ok().
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
var completedTests = 0;
|
||||
var passedTests = 0;
|
||||
|
||||
function receiveMessage(event)
|
||||
{
|
||||
ok_wrapper(event.data.ok, event.data.desc);
|
||||
}
|
||||
|
||||
function ok_wrapper(result, desc) {
|
||||
ok(result, desc);
|
||||
|
||||
completedTests++;
|
||||
|
||||
if (result) {
|
||||
passedTests++;
|
||||
}
|
||||
|
||||
if (completedTests == 13) {
|
||||
is(passedTests, completedTests, "there should be " + completedTests + " passed inheritance tests");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
// fails if bad
|
||||
// 1) an iframe with no sandbox attribute inside an iframe that has sandbox = ""
|
||||
// should not be able to execute scripts (cannot ever loosen permissions)
|
||||
// (done by file_iframe_sandbox_a_if2.html contained within file_iframe_sandbox_a_if1.html)
|
||||
|
||||
// fails if bad
|
||||
// 2) an iframe with sandbox = "allow-scripts" inside an iframe that has sandbox = ""
|
||||
// should not be able to execute scripts (cannot ever loosen permissions)
|
||||
// (done by file_iframe_sandbox_a_if2.html contained within file_iframe_sandbox_a_if1.html)
|
||||
|
||||
// fails if bad
|
||||
// 3) an iframe with no sandbox attribute inside an iframe that has sandbox = "allow-scripts"
|
||||
// should not be same origin with the top window
|
||||
// (done by file_iframe_sandbox_a_if4.html contained within file_iframe_sandbox_a_if3.html)
|
||||
|
||||
// fails if bad
|
||||
// 4) an iframe with no sandbox attribute inside an iframe that has sandbox = "allow-scripts"
|
||||
// should not be same origin with its parent
|
||||
// (done by file_iframe_sandbox_a_if4.html contained within file_iframe_sandbox_a_if3.html)
|
||||
|
||||
// passes if good
|
||||
// 5) an iframe with 'allow-same-origin' and 'allow-scripts' inside an iframe with 'allow-same-origin'
|
||||
// and 'allow-scripts' should be same origin with the top window
|
||||
// (done by file_iframe_sandbox_a_if6.html contained within file_iframe_sandbox_a_if5.html)
|
||||
|
||||
// passes if good
|
||||
// 6) an iframe with 'allow-same-origin' and 'allow-scripts' inside an iframe with 'allow-same-origin'
|
||||
// and 'allow-scripts' should be same origin with its parent
|
||||
// (done by file_iframe_sandbox_a_if6.html contained within file_iframe_sandbox_a_if5.html)
|
||||
|
||||
// passes if good
|
||||
// 7) an iframe with no sandbox attribute inside an iframe that has sandbox = "allow-scripts"
|
||||
// should be able to execute scripts
|
||||
// (done by file_iframe_sandbox_a_if7.html contained within file_iframe_sandbox_a_if3.html)
|
||||
|
||||
// fails if bad
|
||||
// 8) an iframe with sandbox="" inside an iframe that has allow-scripts should not be able
|
||||
// to execute scripts
|
||||
// (done by file_iframe_sandbox_a_if2.html contained within file_iframe_sandbox_a_if3.html)
|
||||
|
||||
// passes if good
|
||||
// 9) make sure that changing the sandbox flags on an iframe (if_8) doesn't affect
|
||||
// the sandboxing of subloads of content within that iframe
|
||||
var if_8 = document.getElementById('if_8');
|
||||
if_8.sandbox = 'allow-scripts';
|
||||
if_8.contentWindow.doSubload();
|
||||
|
||||
// passes if good
|
||||
// 10) a <frame> inside an <iframe> sandboxed with 'allow-scripts' should not be same
|
||||
// origin with this document
|
||||
// done by file_iframe_sandbox_a_if11.html which is contained with file_iframe_sandbox_a_if10.html
|
||||
|
||||
// passes if good
|
||||
// 11) a <frame> inside a <frame> inside an <iframe> sandboxed with 'allow-scripts' should not be same
|
||||
// origin with its parent frame or this document
|
||||
// done by file_iframe_sandbox_a_if12.html which is contained with file_iframe_sandbox_a_if11.html
|
||||
|
||||
// passes if good, fails if bad
|
||||
// 12) An <object> inside an <iframe> sandboxed with 'allow-scripts' should not be same
|
||||
// origin with this document
|
||||
// Done by file_iframe_sandbox_a_if14.html which is contained within file_iframe_sandbox_a_if13.html
|
||||
|
||||
// passes if good, fails if bad
|
||||
// 13) An <object> inside an <object> inside an <iframe> sandboxed with 'allow-scripts' should not be same
|
||||
// origin with its parent frame or this document
|
||||
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if14.html
|
||||
|
||||
// passes if good, fails if bad
|
||||
// 14) An <object> inside a <frame> inside an <iframe> sandboxed with 'allow-scripts' should not be same
|
||||
// origin with its parent frame or this document
|
||||
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if16.html
|
||||
// which is contained within file_iframe_sandbox_a_if10.html
|
||||
|
||||
// passes if good
|
||||
// 15) An <object> inside an <object> inside an <iframe> sandboxed with 'allow-scripts allow-forms'
|
||||
// should be able to submit forms.
|
||||
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if14.html
|
||||
|
||||
// passes if good
|
||||
// 16) An <object> inside a <frame> inside an <iframe> sandboxed with 'allow-scripts allow-forms'
|
||||
// should be able to submit forms.
|
||||
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if16.html
|
||||
// which is contained within file_iframe_sandbox_a_if10.html
|
||||
|
||||
// fails if bad
|
||||
// 17) An <object> inside an <iframe> sandboxed with 'allow-same-origin'
|
||||
// should not be able to run scripts.
|
||||
// Done by iframe "if_no_scripts" using a data: load.
|
||||
|
||||
// passes if good
|
||||
// 18) An <object> inside an <iframe> sandboxed with 'allow-scripts allow-same-origin'
|
||||
// should be able to run scripts and be same origin with this document.
|
||||
// Done by iframe "if_scripts" using a data: load.
|
||||
|
||||
// passes if good, fails if bad
|
||||
// 19) Make sure that the parent's document's sandboxing flags are copied when
|
||||
// changing the sandbox flags on an iframe inside an iframe.
|
||||
// Done in file_iframe_sandbox_a_if17.html and file_iframe_sandbox_a_if18.html
|
||||
}
|
||||
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=341604">Mozilla Bug 341604</a> - Implement HTML5 sandbox attribute for IFRAMEs
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<iframe sandbox="" id="if_1" src="file_iframe_sandbox_a_if1.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts" id="if_3" src="file_iframe_sandbox_a_if3.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-same-origin" id="if_5" src="file_iframe_sandbox_a_if5.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-same-origin" id="if_8" src="file_iframe_sandbox_a_if8.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-forms" id="if_10" src="file_iframe_sandbox_a_if10.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-forms" id="if_13" src="file_iframe_sandbox_a_if13.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin" id="if_no_scripts" src="data:text/html,<object%20data='data:text/html,<script>parent.parent.ok_wrapper(false, "an object inside an iframe sandboxed with only allow-same-origin should not be able to run scripts")</script>'></object>" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-same-origin" id="if_scripts" src="data:text/html,<object%20data='data:text/html,<script>parent.parent.ok_wrapper(true, "an object inside an iframe sandboxed with allow-scripts allow-same-origin should be able to run scripts and call functions in the parent of the iframe")</script>'></object>" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin" id="if_19" src="data:text/html,<iframe%20data='data:text/html,<script>parent.parent.ok_wrapper(true, "an object inside an iframe sandboxed with allow-scripts allow-same-origin should be able to run scripts and call functions in the parent of the iframe")</script>'></object>" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts" id="if_17" src="file_iframe_sandbox_a_if17.html" height="10" width="10"></iframe>
|
||||
</div>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=341604
|
||||
Implement HTML5 sandbox attribute for IFRAMEs - inheritance tests
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 341604</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<script type="application/javascript">
|
||||
/** Test for Bug 341604 - Implement HTML5 sandbox attribute for IFRAMEs **/
|
||||
/** Inheritance Tests **/
|
||||
|
||||
// Assertion failure in docshell/shistory/src/nsSHEntry.cpp (currently line 625).
|
||||
// Bug 901876 raised.
|
||||
SimpleTest.expectAssertions(1);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// A postMessage handler that is used by sandboxed iframes without
|
||||
// 'allow-same-origin' to communicate pass/fail back to this main page.
|
||||
// It expects to be called with an object like {ok: true/false, desc:
|
||||
// <description of the test> which it then forwards to ok().
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
function receiveMessage(event) {
|
||||
switch (event.data.type) {
|
||||
case "attempted":
|
||||
testAttempted();
|
||||
break;
|
||||
case "ok":
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
break;
|
||||
default:
|
||||
// allow for old style message
|
||||
if (event.data.ok != undefined) {
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var attemptedTests = 0;
|
||||
var passedTests = 0;
|
||||
var totalTestsToPass = 15;
|
||||
var totalTestsToAttempt = 19;
|
||||
|
||||
function ok_wrapper(result, desc, addToAttempted = true) {
|
||||
ok(result, desc);
|
||||
|
||||
if (result) {
|
||||
passedTests++;
|
||||
}
|
||||
|
||||
if (addToAttempted) {
|
||||
testAttempted();
|
||||
}
|
||||
}
|
||||
|
||||
// Added so that tests that don't register unless they fail,
|
||||
// can at least notify that they've attempted to run.
|
||||
function testAttempted() {
|
||||
attemptedTests++;
|
||||
if (attemptedTests == totalTestsToAttempt) {
|
||||
// Make sure all tests have had a chance to complete.
|
||||
setTimeout(function() {finish();}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
var finishCalled = false;
|
||||
|
||||
function finish() {
|
||||
if (!finishCalled) {
|
||||
finishCalled = true;
|
||||
is(passedTests, totalTestsToPass, "There are " + totalTestsToPass + " inheritance tests that should pass");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
// fails if bad
|
||||
// 1) an iframe with no sandbox attribute inside an iframe that has sandbox = ""
|
||||
// should not be able to execute scripts (cannot ever loosen permissions)
|
||||
// (done by file_iframe_sandbox_a_if2.html contained within file_iframe_sandbox_a_if1.html)
|
||||
testAttempted();
|
||||
|
||||
// fails if bad
|
||||
// 2) an iframe with sandbox = "allow-scripts" inside an iframe that has sandbox = ""
|
||||
// should not be able to execute scripts (cannot ever loosen permissions)
|
||||
// (done by file_iframe_sandbox_a_if2.html contained within file_iframe_sandbox_a_if1.html)
|
||||
testAttempted();
|
||||
|
||||
// passes if good and fails if bad
|
||||
// 3) an iframe with no sandbox attribute inside an iframe that has sandbox = "allow-scripts"
|
||||
// should not be same origin with the top window
|
||||
// (done by file_iframe_sandbox_a_if4.html contained within file_iframe_sandbox_a_if3.html)
|
||||
|
||||
// passes if good and fails if bad
|
||||
// 4) an iframe with no sandbox attribute inside an iframe that has sandbox = "allow-scripts"
|
||||
// should not be same origin with its parent
|
||||
// (done by file_iframe_sandbox_a_if4.html contained within file_iframe_sandbox_a_if3.html)
|
||||
|
||||
// passes if good
|
||||
// 5) an iframe with 'allow-same-origin' and 'allow-scripts' inside an iframe with 'allow-same-origin'
|
||||
// and 'allow-scripts' should be same origin with the top window
|
||||
// (done by file_iframe_sandbox_a_if6.html contained within file_iframe_sandbox_a_if5.html)
|
||||
|
||||
// passes if good
|
||||
// 6) an iframe with 'allow-same-origin' and 'allow-scripts' inside an iframe with 'allow-same-origin'
|
||||
// and 'allow-scripts' should be same origin with its parent
|
||||
// (done by file_iframe_sandbox_a_if6.html contained within file_iframe_sandbox_a_if5.html)
|
||||
|
||||
// passes if good
|
||||
// 7) an iframe with no sandbox attribute inside an iframe that has sandbox = "allow-scripts"
|
||||
// should be able to execute scripts
|
||||
// (done by file_iframe_sandbox_a_if7.html contained within file_iframe_sandbox_a_if3.html)
|
||||
|
||||
// fails if bad
|
||||
// 8) an iframe with sandbox="" inside an iframe that has allow-scripts should not be able
|
||||
// to execute scripts
|
||||
// (done by file_iframe_sandbox_a_if2.html contained within file_iframe_sandbox_a_if3.html)
|
||||
testAttempted();
|
||||
|
||||
// passes if good
|
||||
// 9) make sure that changing the sandbox flags on an iframe (if_8) doesn't affect
|
||||
// the sandboxing of subloads of content within that iframe
|
||||
var if_8 = document.getElementById('if_8');
|
||||
if_8.sandbox = 'allow-scripts';
|
||||
if_8.contentWindow.doSubload();
|
||||
|
||||
// passes if good
|
||||
// 10) a <frame> inside an <iframe> sandboxed with 'allow-scripts' should not be same
|
||||
// origin with this document
|
||||
// done by file_iframe_sandbox_a_if11.html which is contained with file_iframe_sandbox_a_if10.html
|
||||
|
||||
// passes if good
|
||||
// 11) a <frame> inside a <frame> inside an <iframe> sandboxed with 'allow-scripts' should not be same
|
||||
// origin with its parent frame or this document
|
||||
// done by file_iframe_sandbox_a_if12.html which is contained with file_iframe_sandbox_a_if11.html
|
||||
|
||||
// passes if good, fails if bad
|
||||
// 12) An <object> inside an <iframe> sandboxed with 'allow-scripts' should not be same
|
||||
// origin with this document
|
||||
// Done by file_iframe_sandbox_a_if14.html which is contained within file_iframe_sandbox_a_if13.html
|
||||
|
||||
// passes if good, fails if bad
|
||||
// 13) An <object> inside an <object> inside an <iframe> sandboxed with 'allow-scripts' should not be same
|
||||
// origin with its parent frame or this document
|
||||
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if14.html
|
||||
|
||||
// passes if good, fails if bad
|
||||
// 14) An <object> inside a <frame> inside an <iframe> sandboxed with 'allow-scripts' should not be same
|
||||
// origin with its parent frame or this document
|
||||
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if16.html
|
||||
// which is contained within file_iframe_sandbox_a_if10.html
|
||||
|
||||
// passes if good
|
||||
// 15) An <object> inside an <object> inside an <iframe> sandboxed with 'allow-scripts allow-forms'
|
||||
// should be able to submit forms.
|
||||
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if14.html
|
||||
|
||||
// passes if good
|
||||
// 16) An <object> inside a <frame> inside an <iframe> sandboxed with 'allow-scripts allow-forms'
|
||||
// should be able to submit forms.
|
||||
// Done by file_iframe_sandbox_a_if15.html which is contained within file_iframe_sandbox_a_if16.html
|
||||
// which is contained within file_iframe_sandbox_a_if10.html
|
||||
|
||||
// fails if bad
|
||||
// 17) An <object> inside an <iframe> sandboxed with 'allow-same-origin'
|
||||
// should not be able to run scripts.
|
||||
// Done by iframe "if_no_scripts" using a data: load.
|
||||
testAttempted();
|
||||
|
||||
// passes if good
|
||||
// 18) An <object> inside an <iframe> sandboxed with 'allow-scripts allow-same-origin'
|
||||
// should be able to run scripts and be same origin with this document.
|
||||
// Done by iframe "if_scripts" using a data: load.
|
||||
|
||||
// passes if good, fails if bad
|
||||
// 19) Make sure that the parent's document's sandboxing flags are copied when
|
||||
// changing the sandbox flags on an iframe inside an iframe.
|
||||
// Done in file_iframe_sandbox_a_if17.html and file_iframe_sandbox_a_if18.html
|
||||
}
|
||||
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=341604">Mozilla Bug 341604</a> - Implement HTML5 sandbox attribute for IFRAMEs
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<iframe sandbox="" id="if_1" src="file_iframe_sandbox_a_if1.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts" id="if_3" src="file_iframe_sandbox_a_if3.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-same-origin" id="if_5" src="file_iframe_sandbox_a_if5.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-same-origin" id="if_8" src="file_iframe_sandbox_a_if8.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-forms" id="if_10" src="file_iframe_sandbox_a_if10.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-forms" id="if_13" src="file_iframe_sandbox_a_if13.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin" id="if_no_scripts" src="data:text/html,<object%20data='data:text/html,<script>parent.parent.ok_wrapper(false, "an object inside an iframe sandboxed with only allow-same-origin should not be able to run scripts")</script>'></object>" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-same-origin" id="if_scripts" src="data:text/html,<object%20data='data:text/html,<script>parent.parent.ok_wrapper(true, "an object inside an iframe sandboxed with allow-scripts allow-same-origin should be able to run scripts and call functions in the parent of the iframe")</script>'></object>" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-same-origin" id="if_19" src="data:text/html,<iframe%20data='data:text/html,<script>parent.parent.ok_wrapper(true, "an object inside an iframe sandboxed with allow-scripts allow-same-origin should be able to run scripts and call functions in the parent of the iframe")</script>'></object>" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts" id="if_17" src="file_iframe_sandbox_a_if17.html" height="10" width="10"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=766282
|
||||
implement allow-popups directive for iframe sandbox
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Tests for Bug 766282</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// A postMessage handler that is used by sandboxed iframes without
|
||||
// 'allow-same-origin' to communicate pass/fail back to this main page.
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
function receiveMessage(event) {
|
||||
switch (event.data.type) {
|
||||
case "attempted":
|
||||
testAttempted();
|
||||
break;
|
||||
case "ok":
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
break;
|
||||
default:
|
||||
// allow for old style message
|
||||
if (event.data.ok != undefined) {
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var attemptedTests = 0;
|
||||
var passedTests = 0;
|
||||
var totalTestsToPass = 5;
|
||||
var totalTestsToAttempt = 5;
|
||||
|
||||
function ok_wrapper(result, desc, addToAttempted = true) {
|
||||
ok(result, desc);
|
||||
|
||||
if (result) {
|
||||
passedTests++;
|
||||
}
|
||||
|
||||
if (addToAttempted) {
|
||||
testAttempted();
|
||||
}
|
||||
}
|
||||
|
||||
// Added so that tests that don't register unless they fail,
|
||||
// can at least notify that they've attempted to run.
|
||||
function testAttempted() {
|
||||
attemptedTests++;
|
||||
if (attemptedTests == totalTestsToAttempt) {
|
||||
// Make sure all tests have had a chance to complete.
|
||||
setTimeout(function() {finish();}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
var finishCalled = false;
|
||||
|
||||
function finish() {
|
||||
if (!finishCalled) {
|
||||
finishCalled = true;
|
||||
is(passedTests, totalTestsToPass, "There are " + totalTestsToPass + " modal tests that should pass");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
// passes if good and fails if bad
|
||||
// 1) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups
|
||||
// allow-same-origin" should not have its origin sandbox flag set and be able to access
|
||||
// document.cookie. (Done by file_iframe_sandbox_k_if5.html opened from
|
||||
// file_iframe_sandbox_j_if1.html) using showModalDialog.)
|
||||
|
||||
// passes if good
|
||||
// 2) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups
|
||||
// allow-top-navigation" should not have its top-level navigation sandbox flag set and be able to
|
||||
// navigate top. (Done by file_iframe_sandbox_k_if5.html (and if6) opened from
|
||||
// file_iframe_sandbox_j_if1.html) using showModalDialog.)
|
||||
|
||||
// passes if good
|
||||
// 3) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups
|
||||
// all-forms" should not have its forms sandbox flag set and be able to submit forms.
|
||||
// (Done by file_iframe_sandbox_k_if7.html opened from
|
||||
// file_iframe_sandbox_j_if1.html) using showModalDialog.)
|
||||
|
||||
// passes if good
|
||||
// 4) Make sure that the sandbox flags copied to a new browsing context are taken from the
|
||||
// current active document not the browsing context (iframe / docShell).
|
||||
// This is done by removing allow-same-origin and calling doSubOpens from file_iframe_sandbox_j_if2.html,
|
||||
// which opens file_iframe_sandbox_k_if9.html using showModalDialog.
|
||||
var if_2 = document.getElementById('if_2');
|
||||
if_2.sandbox = 'allow-scripts allow-popups';
|
||||
if_2.contentWindow.doSubOpens();
|
||||
|
||||
// passes if good
|
||||
// 5) Test that a sandboxed iframe with "allow-popups" can open a new window using window.ShowModalDialog.
|
||||
// This is done via file_iframe_sandbox_j_if3.html which is sandboxed with "allow-popups allow-scripts
|
||||
// allow-same-origin". The window it attempts to open calls window.opener.ok(true, ...) and
|
||||
// file_iframe_j_if3.html has an ok() function that calls window.parent.ok_wrapper.
|
||||
}
|
||||
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=766282">Mozilla Bug 766282</a> - implement allow-popups directive for iframe sandbox
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<iframe sandbox="allow-scripts allow-popups allow-same-origin allow-forms allow-top-navigation" id="if_1" src="file_iframe_sandbox_j_if1.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-popups allow-same-origin" id="if_2" src="file_iframe_sandbox_j_if2.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-popups allow-same-origin allow-scripts" id="if_3" src="file_iframe_sandbox_j_if3.html" height="10" width="10"></iframe>
|
||||
</div>
|
|
@ -26,20 +26,26 @@ window.addEventListener("message", receiveMessage, false);
|
|||
var testPassesReceived = 0;
|
||||
|
||||
function receiveMessage(event) {
|
||||
// this message is part of if_10's test
|
||||
if (event.data.test == 'if_10') {
|
||||
doIf10TestPart2();
|
||||
} else if (event.data == "test attempted") {
|
||||
testAttempted();
|
||||
} else {
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
switch (event.data.type) {
|
||||
case "attempted":
|
||||
testAttempted();
|
||||
break;
|
||||
case "ok":
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
break;
|
||||
case "if_10":
|
||||
doIf10TestPart2();
|
||||
break;
|
||||
default:
|
||||
// allow for old style message
|
||||
if (event.data.ok != undefined) {
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Open windows for tests to attempt to navigate later.
|
||||
var windowsToClose = new Array();
|
||||
windowsToClose.push(window.open("about:blank", "window_to_navigate"));
|
||||
windowsToClose.push(window.open("about:blank", "window_to_navigate2"));
|
||||
|
||||
var attemptedTests = 0;
|
||||
var passedTests = 0;
|
||||
|
@ -75,9 +81,7 @@ function finish() {
|
|||
finishCalled = true;
|
||||
is(passedTests, totalTestsToPass, "There are " + totalTestsToPass + " navigation tests that should pass");
|
||||
|
||||
for (var i = 0; i < windowsToClose.length; i++) {
|
||||
windowsToClose[i].close();
|
||||
}
|
||||
closeWindows();
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -86,9 +90,13 @@ function finish() {
|
|||
function checkTestsFinished() {
|
||||
// If our own finish() has not been called, probably failed due to a timeout, so close remaining windows.
|
||||
if (!finishCalled) {
|
||||
for (var i = 0; i < windowsToClose.length; i++) {
|
||||
windowsToClose[i].close();
|
||||
}
|
||||
closeWindows();
|
||||
}
|
||||
}
|
||||
|
||||
function closeWindows() {
|
||||
for (var i = 0; i < windowsToClose.length; i++) {
|
||||
windowsToClose[i].close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,18 @@ window.addEventListener("message", receiveMessage, false);
|
|||
var testPassesReceived = 0;
|
||||
|
||||
function receiveMessage(event) {
|
||||
if (event.data == "test attempted") {
|
||||
testAttempted();
|
||||
} else {
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
switch (event.data.type) {
|
||||
case "attempted":
|
||||
testAttempted();
|
||||
break;
|
||||
case "ok":
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
break;
|
||||
default:
|
||||
// allow for old style message
|
||||
if (event.data.ok != undefined) {
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,11 +45,12 @@ function receiveMessage(event) {
|
|||
var windowsToClose = new Array();
|
||||
windowsToClose.push(window.open("about:blank", "window_to_navigate"));
|
||||
windowsToClose.push(window.open("about:blank", "window_to_navigate2"));
|
||||
var iframesWithWindowsToClose = new Array();
|
||||
|
||||
var attemptedTests = 0;
|
||||
var passedTests = 0;
|
||||
var totalTestsToPass = 10;
|
||||
var totalTestsToAttempt = 13;
|
||||
var totalTestsToPass = 12;
|
||||
var totalTestsToAttempt = 15;
|
||||
|
||||
function ok_wrapper(result, desc, addToAttempted = true) {
|
||||
ok(result, desc);
|
||||
|
@ -168,6 +177,19 @@ function doTest() {
|
|||
// file_iframe_sandbox_e_if15.html contains file_iframe_sandbox_e_if16.html, which
|
||||
// attempts to navigate top by name using window.open().
|
||||
window.open("file_iframe_sandbox_e_if15.html");
|
||||
|
||||
// passes if good
|
||||
// 27) iframe with sandbox='allow-scripts allow-popups' should be able to
|
||||
// navigate a window, that it has opened, using it's name.
|
||||
// file_iframe_sandbox_d_if23.html in if_23 opens a window and then attempts
|
||||
// to navigate it using it's name in the target of an anchor.
|
||||
iframesWithWindowsToClose.push("if_23");
|
||||
|
||||
// passes if good, fails if bad
|
||||
// 28) iframe with sandbox='allow-scripts allow-popups' should be able to
|
||||
// navigate a window, that it has opened, using window.open(..., "<name>").
|
||||
// file_iframe_sandbox_d_if23.html in if_23 opens a window and then attempts
|
||||
// to navigate it using it's name in the target of window.open().
|
||||
}
|
||||
|
||||
addLoadEvent(doTest);
|
||||
|
@ -182,6 +204,7 @@ addLoadEvent(doTest);
|
|||
<iframe sandbox="allow-scripts" id="if_18" src="file_iframe_sandbox_d_if18.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts" id="if_19" src="file_iframe_sandbox_d_if19.html" height="10" width="10"></iframe>
|
||||
<iframe id="if_21" name="if_parent2" src="file_iframe_sandbox_d_if21.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-popups" id="if_23" src="file_iframe_sandbox_d_if23.html" height="10" width="10"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=766282
|
||||
implement allow-popups directive for iframe sandbox
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Tests for Bug 766282</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// a postMessage handler that is used by sandboxed iframes without
|
||||
// 'allow-same-origin' to communicate pass/fail back to this main page.
|
||||
// it expects to be called with an object like {ok: true/false, desc:
|
||||
// <description of the test> which it then forwards to ok()
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
function receiveMessage(event)
|
||||
{
|
||||
ok_wrapper(event.data.ok, event.data.desc);
|
||||
}
|
||||
|
||||
var completedTests = 0;
|
||||
var passedTests = 0;
|
||||
|
||||
function ok_wrapper(result, desc) {
|
||||
ok(result, desc);
|
||||
|
||||
completedTests++;
|
||||
|
||||
if (result) {
|
||||
passedTests++;
|
||||
}
|
||||
|
||||
if (completedTests == 3) {
|
||||
is(passedTests, completedTests, "There are " + completedTests + " popups tests that should pass");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
// passes if good
|
||||
// 1) Test that a sandboxed iframe with "allow-popups" can open a new window using the target.attribute.
|
||||
// This is done via file_iframe_sandbox_h_if1.html which is sandboxed with "allow-popups allow-scripts allow-same-origin".
|
||||
// The window it attempts to open calls window.opener.ok(true, ...) and file_iframe_h_if1.html has an ok()
|
||||
// function that calls window.parent.ok_wrapper.
|
||||
|
||||
// passes if good
|
||||
// 2) Test that a sandboxed iframe with "allow-popups" can open a new window using window.open.
|
||||
// This is done via file_iframe_sandbox_h_if1.html which is sandboxed with "allow-popups allow-scripts allow-same-origin".
|
||||
// The window it attempts to open calls window.opener.ok(true, ...) and file_iframe_h_if1.html has an ok()
|
||||
// function that calls window.parent.ok_wrapper.
|
||||
|
||||
// passes if good, fails if bad
|
||||
// 3) Test that a sandboxed iframe with "allow-popups" can open a new window using the target.attribute
|
||||
// for a non-existing browsing context (BC766282).
|
||||
// This is done via file_iframe_sandbox_h_if1.html which is sandboxed with "allow-popups allow-scripts allow-same-origin".
|
||||
// The window it attempts to open calls window.opener.ok(true, ...) and file_iframe_h_if1.html has an ok()
|
||||
// function that calls window.parent.ok_wrapper.
|
||||
}
|
||||
|
||||
addLoadEvent(doTest);
|
||||
|
||||
</script>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=766282">Mozilla Bug 766282</a> - implement allow-popups directive for iframe sandbox
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<iframe sandbox="allow-popups allow-same-origin allow-scripts" id="if1" src="file_iframe_sandbox_h_if1.html" height="10" width="10"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,156 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=766282
|
||||
Implement HTML5 sandbox allow-popuos directive for IFRAMEs - inheritance tests
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Tests for Bug 766282</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.expectAssertions(0, 5);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// A postMessage handler that is used by sandboxed iframes without
|
||||
// 'allow-same-origin' to communicate pass/fail back to this main page.
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
function receiveMessage(event) {
|
||||
switch (event.data.type) {
|
||||
case "attempted":
|
||||
testAttempted();
|
||||
break;
|
||||
case "ok":
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
break;
|
||||
default:
|
||||
// allow for old style message
|
||||
if (event.data.ok != undefined) {
|
||||
ok_wrapper(event.data.ok, event.data.desc, event.data.addToAttempted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var iframesWithWindowsToClose = new Array();
|
||||
|
||||
var attemptedTests = 0;
|
||||
var passedTests = 0;
|
||||
var totalTestsToPass = 15;
|
||||
var totalTestsToAttempt = 21;
|
||||
|
||||
function ok_wrapper(result, desc, addToAttempted = true) {
|
||||
ok(result, desc);
|
||||
|
||||
if (result) {
|
||||
passedTests++;
|
||||
}
|
||||
|
||||
if (addToAttempted) {
|
||||
testAttempted();
|
||||
}
|
||||
}
|
||||
|
||||
// Added so that tests that don't register unless they fail,
|
||||
// can at least notify that they've attempted to run.
|
||||
function testAttempted() {
|
||||
attemptedTests++;
|
||||
if (attemptedTests == totalTestsToAttempt) {
|
||||
// Make sure all tests have had a chance to complete.
|
||||
setTimeout(function() {finish();}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
var finishCalled = false;
|
||||
|
||||
function finish() {
|
||||
if (!finishCalled) {
|
||||
finishCalled = true;
|
||||
is(passedTests, totalTestsToPass, "There are " + totalTestsToPass + " inheritance tests that should pass");
|
||||
|
||||
closeWindows();
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function checkTestsFinished() {
|
||||
// If our own finish() has not been called, probably failed due to a timeout, so close remaining windows.
|
||||
if (!finishCalled) {
|
||||
closeWindows();
|
||||
}
|
||||
}
|
||||
|
||||
function closeWindows() {
|
||||
for (var i = 0; i < iframesWithWindowsToClose.length; i++) {
|
||||
document.getElementById(iframesWithWindowsToClose[i]).contentWindow.postMessage({type: "closeWindows"}, "*");
|
||||
}
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
// passes if good and fails if bad
|
||||
// 1,2,3) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups
|
||||
// allow-same-origin" should not have its origin sandbox flag set and be able to access document.cookie.
|
||||
// (Done by file_iframe_sandbox_k_if5.html opened from file_iframe_sandbox_k_if4.html)
|
||||
// This is repeated for 3 different ways of opening the window,
|
||||
// see file_iframe_sandbox_k_if4.html for details.
|
||||
|
||||
// passes if good
|
||||
// 4,5,6) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups
|
||||
// allow-top-navigation" should not have its top-level navigation sandbox flag set and be able to
|
||||
// navigate top. (Done by file_iframe_sandbox_k_if5.html (and if6) opened from
|
||||
// file_iframe_sandbox_k_if4.html). This is repeated for 3 different ways of opening the window,
|
||||
// see file_iframe_sandbox_k_if4.html for details.
|
||||
|
||||
// passes if good
|
||||
// 7,8,9) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups
|
||||
// all-forms" should not have its forms sandbox flag set and be able to submit forms.
|
||||
// (Done by file_iframe_sandbox_k_if7.html opened from file_iframe_sandbox_k_if4.html)
|
||||
// This is repeated for 3 different ways of opening the window,
|
||||
// see file_iframe_sandbox_k_if4.html for details.
|
||||
|
||||
// passes if good
|
||||
// 10,11,12) Make sure that the sandbox flags copied to a new browsing context are taken from the
|
||||
// current active document not the browsing context (iframe / docShell).
|
||||
// This is done by removing allow-same-origin and calling doSubOpens from file_iframe_sandbox_k_if8.html,
|
||||
// which opens file_iframe_sandbox_k_if9.html in 3 different ways.
|
||||
// It then navigates to file_iframe_sandbox_k_if1.html to run tests 13 - 21 below.
|
||||
var if_8_1 = document.getElementById('if_8_1');
|
||||
if_8_1.sandbox = 'allow-scripts allow-popups';
|
||||
if_8_1.contentWindow.doSubOpens();
|
||||
|
||||
// passes if good and fails if bad
|
||||
// 13,14,15) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups"
|
||||
// should have its origin sandbox flag set and not be able to access document.cookie.
|
||||
// This is done by file_iframe_sandbox_k_if8.html navigating to file_iframe_sandbox_k_if1.html
|
||||
// after allow-same-origin has been removed from iframe if_8_1. file_iframe_sandbox_k_if1.html
|
||||
// opens file_iframe_sandbox_k_if2.html in 3 different ways to perform the tests.
|
||||
iframesWithWindowsToClose.push("if_8_1");
|
||||
|
||||
// fails if bad
|
||||
// 16,17,18) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups"
|
||||
// should have its forms sandbox flag set and not be able to submit forms.
|
||||
// This is done by file_iframe_sandbox_k_if2.html, see test 10 for details of how this is opened.
|
||||
|
||||
// fails if bad
|
||||
// 19,20,21) A window opened from inside an iframe that has sandbox = "allow-scripts allow-popups"
|
||||
// should have its top-level navigation sandbox flag set and not be able to navigate top.
|
||||
// This is done by file_iframe_sandbox_k_if2.html, see test 10 for details of how this is opened.
|
||||
}
|
||||
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
|
||||
<body onunload="checkTestsFinished()">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=766282">Mozilla Bug 766282</a> - Implement HTML5 sandbox allow-popups directive for IFRAMEs
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<iframe sandbox="allow-scripts allow-popups allow-same-origin allow-forms allow-top-navigation" id="if_4" src="file_iframe_sandbox_k_if4.html" height="10" width="10"></iframe>
|
||||
<iframe sandbox="allow-scripts allow-popups allow-same-origin" id="if_8_1" src="file_iframe_sandbox_k_if8.html" height="10" width="10"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -371,7 +371,7 @@ nsXBLProtoImplField::InstallAccessors(JSContext* aCx,
|
|||
// Now, re-enter the class object's scope, wrap the getters/setters, and define
|
||||
// them there.
|
||||
JSAutoCompartment ac2(aCx, aTargetClassObject);
|
||||
if (!JS_WrapObject(aCx, get.address()) || !JS_WrapObject(aCx, set.address()) ||
|
||||
if (!JS_WrapObject(aCx, &get) || !JS_WrapObject(aCx, &set) ||
|
||||
!JS_WrapId(aCx, id.address()))
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -424,7 +424,7 @@ nsXBLProtoImplField::InstallField(nsIScriptContext* aContext,
|
|||
JSAutoCompartment ac(cx, scopeObject);
|
||||
|
||||
JS::Rooted<JSObject*> wrappedNode(cx, aBoundNode);
|
||||
if (!JS_WrapObject(cx, wrappedNode.address()))
|
||||
if (!JS_WrapObject(cx, &wrappedNode))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
JS::Rooted<JS::Value> result(cx);
|
||||
|
|
|
@ -121,7 +121,7 @@ nsXBLProtoImplMethod::InstallMember(JSContext* aCx,
|
|||
// Then, enter the content compartment, wrap the method pointer, and define
|
||||
// the wrapped version on the class object.
|
||||
JSAutoCompartment ac2(aCx, aTargetClassObject);
|
||||
if (!JS_WrapObject(aCx, method.address()))
|
||||
if (!JS_WrapObject(aCx, &method))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
JS::Rooted<JS::Value> value(aCx, JS::ObjectValue(*method));
|
||||
|
@ -327,7 +327,7 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement)
|
|||
NS_ENSURE_TRUE(scopeObject, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JSAutoCompartment ac(cx, scopeObject);
|
||||
if (!JS_WrapObject(cx, thisObject.address()))
|
||||
if (!JS_WrapObject(cx, &thisObject))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// Clone the function object, using thisObject as the parent so "this" is in
|
||||
|
|
|
@ -152,8 +152,8 @@ nsXBLProtoImplProperty::InstallMember(JSContext *aCx,
|
|||
// them on the class object.
|
||||
JSAutoCompartment ac2(aCx, aTargetClassObject);
|
||||
nsDependentString name(mName);
|
||||
if (!JS_WrapObject(aCx, getter.address()) ||
|
||||
!JS_WrapObject(aCx, setter.address()) ||
|
||||
if (!JS_WrapObject(aCx, &getter) ||
|
||||
!JS_WrapObject(aCx, &setter) ||
|
||||
!::JS_DefineUCProperty(aCx, aTargetClassObject,
|
||||
static_cast<const jschar*>(mName),
|
||||
name.Length(), JSVAL_VOID,
|
||||
|
|
|
@ -299,7 +299,7 @@ nsXBLPrototypeHandler::ExecuteHandler(EventTarget* aTarget,
|
|||
// been compiled, above.
|
||||
JSAutoCompartment ac(cx, scopeObject);
|
||||
JS::Rooted<JSObject*> genericHandler(cx, handler.get());
|
||||
bool ok = JS_WrapObject(cx, genericHandler.address());
|
||||
bool ok = JS_WrapObject(cx, &genericHandler);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
||||
MOZ_ASSERT(!js::IsCrossCompartmentWrapper(genericHandler));
|
||||
|
||||
|
@ -317,7 +317,7 @@ nsXBLPrototypeHandler::ExecuteHandler(EventTarget* aTarget,
|
|||
|
||||
// Now, wrap the bound handler into the content compartment and use it.
|
||||
JSAutoCompartment ac2(cx, globalObject);
|
||||
if (!JS_WrapObject(cx, bound.address())) {
|
||||
if (!JS_WrapObject(cx, &bound)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ nsXBLPrototypeHandler::EnsureEventHandler(nsIScriptGlobalObject* aGlobal,
|
|||
// Wrap the handler into the content scope, since we're about to stash it
|
||||
// on the DOM window and such.
|
||||
JSAutoCompartment ac2(cx, globalObject);
|
||||
bool ok = JS_WrapObject(cx, handlerFun.address());
|
||||
bool ok = JS_WrapObject(cx, &handlerFun);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
||||
aHandler.set(handlerFun);
|
||||
NS_ENSURE_TRUE(aHandler, NS_ERROR_FAILURE);
|
||||
|
|
|
@ -3190,62 +3190,11 @@ nsDocShell::FindItemWithName(const PRUnichar * aName,
|
|||
// DoFindItemWithName only returns active items and we don't check if
|
||||
// the item is active for the special cases.
|
||||
if (foundItem) {
|
||||
|
||||
// If our document is sandboxed, we need to do some extra checks.
|
||||
uint32_t sandboxFlags = 0;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_GetInterface(aOriginalRequestor);
|
||||
|
||||
if (doc) {
|
||||
sandboxFlags = doc->GetSandboxFlags();
|
||||
if (IsSandboxedFrom(foundItem, aOriginalRequestor)) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
} else {
|
||||
foundItem.swap(*_retval);
|
||||
}
|
||||
|
||||
if (sandboxFlags) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||
GetSameTypeRootTreeItem(getter_AddRefs(root));
|
||||
|
||||
// Is the found item not a top level browsing context and not ourself ?
|
||||
nsCOMPtr<nsIDocShellTreeItem> selfAsItem = static_cast<nsIDocShellTreeItem *>(this);
|
||||
if (foundItem != root && foundItem != selfAsItem) {
|
||||
// Are we an ancestor of the foundItem ?
|
||||
bool isAncestor = false;
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
|
||||
foundItem->GetSameTypeParent(getter_AddRefs(parentAsItem));
|
||||
while (parentAsItem) {
|
||||
if (parentAsItem == selfAsItem) {
|
||||
isAncestor = true;
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIDocShellTreeItem> tmp = parentAsItem;
|
||||
tmp->GetSameTypeParent(getter_AddRefs(parentAsItem));
|
||||
}
|
||||
|
||||
if (!isAncestor) {
|
||||
// No, we are not an ancestor and our document is
|
||||
// sandboxed, we can't allow this.
|
||||
foundItem = nullptr;
|
||||
}
|
||||
} else {
|
||||
// Top level browsing context - is it an ancestor of ours ?
|
||||
nsCOMPtr<nsIDocShellTreeItem> tmp;
|
||||
GetSameTypeParent(getter_AddRefs(tmp));
|
||||
|
||||
while (tmp) {
|
||||
if (tmp && tmp == foundItem) {
|
||||
// This is an ancestor, and we are sandboxed.
|
||||
// Unless allow-top-navigation is set, we can't allow this.
|
||||
if (sandboxFlags & SANDBOXED_TOPLEVEL_NAVIGATION) {
|
||||
foundItem = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
tmp->GetParent(getter_AddRefs(tmp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foundItem.swap(*_retval);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3318,6 +3267,70 @@ nsDocShell::DoFindItemWithName(const PRUnichar* aName,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
nsDocShell::IsSandboxedFrom(nsIDocShellTreeItem* aTargetItem,
|
||||
nsIDocShellTreeItem* aAccessingItem)
|
||||
{
|
||||
// aAccessingItem cannot be sandboxed from itself.
|
||||
if (SameCOMIdentity(aTargetItem, aAccessingItem)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t sandboxFlags = 0;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_GetInterface(aAccessingItem);
|
||||
if (doc) {
|
||||
sandboxFlags = doc->GetSandboxFlags();
|
||||
}
|
||||
|
||||
// If no flags, aAccessingItem is not sandboxed at all.
|
||||
if (!sandboxFlags) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If aTargetItem has an ancestor, it is not top level.
|
||||
nsCOMPtr<nsIDocShellTreeItem> ancestorOfTarget;
|
||||
aTargetItem->GetSameTypeParent(getter_AddRefs(ancestorOfTarget));
|
||||
if (ancestorOfTarget) {
|
||||
do {
|
||||
// aAccessingItem is not sandboxed if it is an ancestor of target.
|
||||
if (SameCOMIdentity(aAccessingItem, ancestorOfTarget)) {
|
||||
return false;
|
||||
}
|
||||
nsCOMPtr<nsIDocShellTreeItem> tempTreeItem;
|
||||
ancestorOfTarget->GetSameTypeParent(getter_AddRefs(tempTreeItem));
|
||||
tempTreeItem.swap(ancestorOfTarget);
|
||||
} while (ancestorOfTarget);
|
||||
|
||||
// Otherwise, aAccessingItem is sandboxed from aTargetItem.
|
||||
return true;
|
||||
}
|
||||
|
||||
// aTargetItem is top level, is aAccessingItem the "one permitted sandboxed
|
||||
// navigator", i.e. did aAccessingItem open aTargetItem?
|
||||
nsCOMPtr<nsIDocShell> targetDocShell = do_QueryInterface(aTargetItem);
|
||||
nsCOMPtr<nsIDocShell> permittedNavigator;
|
||||
targetDocShell->
|
||||
GetOnePermittedSandboxedNavigator(getter_AddRefs(permittedNavigator));
|
||||
if (SameCOMIdentity(aAccessingItem, permittedNavigator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If SANDBOXED_TOPLEVEL_NAVIGATION flag is not on, aAccessingItem is
|
||||
// not sandboxed from its top.
|
||||
if (!(sandboxFlags & SANDBOXED_TOPLEVEL_NAVIGATION)) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> rootTreeItem;
|
||||
aAccessingItem->GetSameTypeRootTreeItem(getter_AddRefs(rootTreeItem));
|
||||
if (SameCOMIdentity(aTargetItem, rootTreeItem)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, aAccessingItem is sandboxed from aTargetItem.
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetTreeOwner(nsIDocShellTreeOwner ** aTreeOwner)
|
||||
{
|
||||
|
@ -5055,6 +5068,8 @@ nsDocShell::Destroy()
|
|||
|
||||
SetTreeOwner(nullptr);
|
||||
|
||||
mOnePermittedSandboxedNavigator = nullptr;
|
||||
|
||||
// required to break ref cycle
|
||||
mSecurityUI = nullptr;
|
||||
|
||||
|
@ -5403,6 +5418,31 @@ nsDocShell::GetSandboxFlags(uint32_t *aSandboxFlags)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetOnePermittedSandboxedNavigator(nsIDocShell* aSandboxedNavigator)
|
||||
{
|
||||
if (mOnePermittedSandboxedNavigator) {
|
||||
NS_ERROR("One Permitted Sandboxed Navigator should only be set once.");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mOnePermittedSandboxedNavigator = do_GetWeakReference(aSandboxedNavigator);
|
||||
NS_ASSERTION(mOnePermittedSandboxedNavigator,
|
||||
"One Permitted Sandboxed Navigator must support weak references.");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetOnePermittedSandboxedNavigator(nsIDocShell** aSandboxedNavigator)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSandboxedNavigator);
|
||||
nsCOMPtr<nsIDocShell> permittedNavigator =
|
||||
do_QueryReferent(mOnePermittedSandboxedNavigator);
|
||||
NS_IF_ADDREF(*aSandboxedNavigator = permittedNavigator);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetDefaultLoadFlags(uint32_t aDefaultLoadFlags)
|
||||
{
|
||||
|
@ -8719,8 +8759,10 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
|||
if (aWindowTarget && *aWindowTarget) {
|
||||
// Locate the target DocShell.
|
||||
nsCOMPtr<nsIDocShellTreeItem> targetItem;
|
||||
FindItemWithName(aWindowTarget, nullptr, this,
|
||||
getter_AddRefs(targetItem));
|
||||
if (FindItemWithName(aWindowTarget, nullptr, this,
|
||||
getter_AddRefs(targetItem)) == NS_ERROR_DOM_INVALID_ACCESS_ERR) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
}
|
||||
|
||||
targetDocShell = do_QueryInterface(targetItem);
|
||||
// If the targetDocShell doesn't exist, then this is a new docShell
|
||||
|
@ -8847,19 +8889,17 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
|||
|
||||
bool isNewWindow = false;
|
||||
if (!targetDocShell) {
|
||||
// If the docshell's document is sandboxed and was trying to
|
||||
// navigate/load a frame it wasn't allowed to access, the
|
||||
// FindItemWithName above will have returned null for the target
|
||||
// item - we don't want to actually open a new window in this case
|
||||
// though. Check if we are sandboxed and bail out here if so.
|
||||
// If the docshell's document is sandboxed, only open a new window
|
||||
// if the document's SANDBOXED_AUXILLARY_NAVIGATION flag is not set.
|
||||
// (i.e. if allow-popups is specified)
|
||||
NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE);
|
||||
nsIDocument* doc = mContentViewer->GetDocument();
|
||||
uint32_t sandboxFlags = 0;
|
||||
|
||||
if (doc) {
|
||||
sandboxFlags = doc->GetSandboxFlags();
|
||||
if (sandboxFlags & SANDBOXED_NAVIGATION) {
|
||||
return NS_ERROR_FAILURE;
|
||||
if (sandboxFlags & SANDBOXED_AUXILIARY_NAVIGATION) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -771,6 +771,7 @@ protected:
|
|||
int32_t mLoadedTransIndex;
|
||||
|
||||
uint32_t mSandboxFlags;
|
||||
nsWeakPtr mOnePermittedSandboxedNavigator;
|
||||
|
||||
// mFullscreenAllowed stores how we determine whether fullscreen is allowed
|
||||
// when GetFullscreenAllowed() is called. Fullscreen is allowed in a
|
||||
|
@ -880,6 +881,10 @@ private:
|
|||
nsIDocShellTreeItem* aOriginalRequestor,
|
||||
nsIDocShellTreeItem** _retval);
|
||||
|
||||
// Check whether accessing item is sandboxed from the target item.
|
||||
static bool IsSandboxedFrom(nsIDocShellTreeItem* aTargetItem,
|
||||
nsIDocShellTreeItem* aAccessingItem);
|
||||
|
||||
#ifdef DEBUG
|
||||
// We're counting the number of |nsDocShells| to help find leaks
|
||||
static unsigned long gNumberOfDocShells;
|
||||
|
|
|
@ -43,7 +43,7 @@ interface nsIReflowObserver;
|
|||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
[scriptable, builtinclass, uuid(5f4d82fc-3220-4f7e-9b00-626f1033318a)]
|
||||
[scriptable, builtinclass, uuid(4ca172c3-67bf-4e6d-89a3-cbfb929c370d)]
|
||||
interface nsIDocShell : nsIDocShellTreeItem
|
||||
{
|
||||
/**
|
||||
|
@ -798,6 +798,13 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
*/
|
||||
attribute unsigned long sandboxFlags;
|
||||
|
||||
/**
|
||||
* When a new browsing context is opened by a sandboxed document, it needs to
|
||||
* keep track of the browsing context that opened it, so that it can be
|
||||
* navigated by it. This is the "one permitted sandboxed navigator".
|
||||
*/
|
||||
attribute nsIDocShell onePermittedSandboxedNavigator;
|
||||
|
||||
/**
|
||||
* This member variable determines whether a document has Mixed Active Content that
|
||||
* was initially blocked from loading, but the user has choosen to override the
|
||||
|
|
|
@ -139,7 +139,7 @@ PostMessageReadStructuredClone(JSContext* cx,
|
|||
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
|
||||
if (global) {
|
||||
JS::Rooted<JSObject*> obj(cx, port->WrapObject(cx, global));
|
||||
if (JS_WrapObject(cx, obj.address())) {
|
||||
if (JS_WrapObject(cx, &obj)) {
|
||||
port->BindToOwner(scInfo->mPort->GetOwner());
|
||||
return obj;
|
||||
}
|
||||
|
|
|
@ -1554,7 +1554,7 @@ Navigator::DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
|
|||
}
|
||||
}
|
||||
|
||||
if (!JS_WrapObject(aCx, domObject.address())) {
|
||||
if (!JS_WrapObject(aCx, &domObject)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2785,7 +2785,7 @@ GetXPCProto(nsIXPConnect *aXPConnect, JSContext *cx, nsGlobalWindow *aWin,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::Rooted<JSObject*> proto_obj(cx, (*aProto)->GetJSObject());
|
||||
if (!JS_WrapObject(cx, proto_obj.address())) {
|
||||
if (!JS_WrapObject(cx, &proto_obj)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -2922,7 +2922,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
|||
if (proto &&
|
||||
(!xpc_proto_proto ||
|
||||
JS_GetClass(xpc_proto_proto) == sObjectClass)) {
|
||||
if (!JS_WrapObject(cx, proto.address()) ||
|
||||
if (!JS_WrapObject(cx, &proto) ||
|
||||
!JS_SetPrototype(cx, dot_prototype, proto)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
@ -3071,7 +3071,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
|||
if (defineOnXray) {
|
||||
// This really should be handled by the Xray for the window.
|
||||
ac.destroy();
|
||||
if (!JS_WrapObject(cx, interfaceObject.address()) ||
|
||||
if (!JS_WrapObject(cx, &interfaceObject) ||
|
||||
!JS_DefinePropertyById(cx, obj, id,
|
||||
JS::ObjectValue(*interfaceObject), JS_PropertyStub,
|
||||
JS_StrictPropertyStub, 0)) {
|
||||
|
@ -3644,7 +3644,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
}
|
||||
funObj = ::JS_GetFunctionObject(fun);
|
||||
|
||||
if (!JS_WrapObject(cx, funObj.address()) ||
|
||||
if (!JS_WrapObject(cx, &funObj) ||
|
||||
!JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
|
||||
JS_DATA_TO_FUNC_PTR(JSPropertyOp, funObj.get()),
|
||||
JS_StrictPropertyStub,
|
||||
|
@ -3745,7 +3745,7 @@ nsWindowSH::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
|||
// might not be. If we're running script in an inactive scope and evalute
|
||||
// |this|, the outer window is actually a cross-compartment wrapper. So we
|
||||
// need to wrap here.
|
||||
if (!JS_WrapObject(cx, winObj.address())) {
|
||||
if (!JS_WrapObject(cx, &winObj)) {
|
||||
*_retval = nullptr;
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
|
|
@ -4005,8 +4005,8 @@ nsGlobalWindow::SetOpener(nsIDOMWindow* aOpener)
|
|||
JS::Rooted<JSObject*> thisObj(cx, mJSObject);
|
||||
NS_ENSURE_STATE(mJSObject);
|
||||
|
||||
if (!JS_WrapObject(cx, otherObj.address()) ||
|
||||
!JS_WrapObject(cx, thisObj.address()) ||
|
||||
if (!JS_WrapObject(cx, &otherObj) ||
|
||||
!JS_WrapObject(cx, &thisObj) ||
|
||||
!JS_DefineProperty(cx, thisObj, "opener", JS::ObjectValue(*otherObj),
|
||||
JS_PropertyStub, JS_StrictPropertyStub,
|
||||
JSPROP_ENUMERATE)) {
|
||||
|
@ -6822,7 +6822,7 @@ PostMessageReadStructuredClone(JSContext* cx,
|
|||
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
|
||||
if (global) {
|
||||
JS::Rooted<JSObject*> obj(cx, port->WrapObject(cx, global));
|
||||
if (JS_WrapObject(cx, obj.address())) {
|
||||
if (JS_WrapObject(cx, &obj)) {
|
||||
port->BindToOwner(scInfo->window);
|
||||
return obj;
|
||||
}
|
||||
|
|
|
@ -689,7 +689,7 @@ NativeInterface2JSObjectAndThrowIfFailed(JSContext* aCx,
|
|||
obj = cache->WrapObject(aCx, aScope);
|
||||
}
|
||||
|
||||
if (obj && aAllowNativeWrapper && !JS_WrapObject(aCx, obj.address())) {
|
||||
if (obj && aAllowNativeWrapper && !JS_WrapObject(aCx, &obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1268,7 +1268,7 @@ WrapCallThisObject(JSContext* cx, JS::Handle<JSObject*> scope, const T& p)
|
|||
}
|
||||
|
||||
// But all that won't necessarily put things in the compartment of cx.
|
||||
if (!JS_WrapObject(cx, obj.address())) {
|
||||
if (!JS_WrapObject(cx, &obj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -4611,9 +4611,9 @@ def wrapTypeIntoCurrentCompartment(type, value, isMember=True):
|
|||
|
||||
if type.isObject():
|
||||
if isMember:
|
||||
value = "&%s" % value
|
||||
value = "JS::MutableHandleObject::fromMarkedLocation(&%s)" % value
|
||||
else:
|
||||
value = value + ".address()"
|
||||
value = "&" + value
|
||||
return CGGeneric("if (!JS_WrapObject(cx, %s)) {\n"
|
||||
" return false;\n"
|
||||
"}" % value)
|
||||
|
@ -9905,7 +9905,7 @@ class CGJSImplClass(CGBindingImplClass):
|
|||
"\n"
|
||||
"// Now define it on our chrome object\n"
|
||||
"JSAutoCompartment ac(aCx, mImpl->Callback());\n"
|
||||
"if (!JS_WrapObject(aCx, obj.address())) {\n"
|
||||
"if (!JS_WrapObject(aCx, &obj)) {\n"
|
||||
" return nullptr;\n"
|
||||
"}\n"
|
||||
'if (!JS_DefineProperty(aCx, mImpl->Callback(), "__DOM_IMPL__", JS::ObjectValue(*obj), nullptr, nullptr, 0)) {\n'
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
|
||||
inline bool WrapIntoNewCompartment(JSContext* cx)
|
||||
{
|
||||
return JS_WrapObject(cx, &mObj);
|
||||
return JS_WrapObject(cx, JS::MutableHandleObject::fromMarkedLocation(&mObj));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -294,7 +294,9 @@ TabParent::ActorDestroy(ActorDestroyReason why)
|
|||
}
|
||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
nsRefPtr<nsFrameMessageManager> fmm;
|
||||
if (frameLoader) {
|
||||
fmm = frameLoader->GetFrameMessageManager();
|
||||
nsCOMPtr<Element> frameElement(mFrameElement);
|
||||
ReceiveMessage(CHILD_PROCESS_SHUTDOWN_MESSAGE, false, nullptr, nullptr);
|
||||
frameLoader->DestroyChild();
|
||||
|
@ -311,6 +313,9 @@ TabParent::ActorDestroy(ActorDestroyReason why)
|
|||
if (os) {
|
||||
os->NotifyObservers(NS_ISUPPORTS_CAST(nsITabParent*, this), "ipc:browser-destroyed", nullptr);
|
||||
}
|
||||
if (fmm) {
|
||||
fmm->Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -1075,7 +1075,7 @@ GetNPObjectWrapper(JSContext *cx, JSObject *aObj, bool wrapResult = true)
|
|||
JS::Rooted<JSObject*> obj(cx, aObj);
|
||||
while (obj && (obj = js::CheckedUnwrap(obj))) {
|
||||
if (JS_GetClass(obj) == &sNPObjectJSWrapperClass) {
|
||||
if (wrapResult && !JS_WrapObject(cx, obj.address())) {
|
||||
if (wrapResult && !JS_WrapObject(cx, &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
return obj;
|
||||
|
@ -1730,7 +1730,7 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj)
|
|||
// npobj is one of our own, return its existing JSObject.
|
||||
|
||||
JS::Rooted<JSObject*> obj(cx, ((nsJSObjWrapper *)npobj)->mJSObj);
|
||||
if (!JS_WrapObject(cx, obj.address())) {
|
||||
if (!JS_WrapObject(cx, &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
return obj;
|
||||
|
@ -1767,7 +1767,7 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj)
|
|||
// Found a live NPObject wrapper. It may not be in the same compartment
|
||||
// as cx, so we need to wrap it before returning it.
|
||||
JS::Rooted<JSObject*> obj(cx, entry->mJSObj);
|
||||
if (!JS_WrapObject(cx, obj.address())) {
|
||||
if (!JS_WrapObject(cx, &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
return obj;
|
||||
|
|
|
@ -225,23 +225,6 @@ private:
|
|||
nsRefPtr<Geolocation> mLocator;
|
||||
};
|
||||
|
||||
class RequestRestartTimerEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
RequestRestartTimerEvent(nsGeolocationRequest* aRequest)
|
||||
: mRequest(aRequest)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run() {
|
||||
mRequest->SetTimeoutTimer();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<nsGeolocationRequest> mRequest;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// PositionError
|
||||
////////////////////////////////////////////////////
|
||||
|
@ -636,14 +619,12 @@ NS_IMPL_RELEASE(nsGeolocationService)
|
|||
|
||||
static bool sGeoEnabled = true;
|
||||
static bool sGeoInitPending = true;
|
||||
static bool sGeoIgnoreLocationFilter = false;
|
||||
static int32_t sProviderTimeout = 6000; // Time, in milliseconds, to wait for the location provider to spin up.
|
||||
|
||||
nsresult nsGeolocationService::Init()
|
||||
{
|
||||
Preferences::AddIntVarCache(&sProviderTimeout, "geo.timeout", sProviderTimeout);
|
||||
Preferences::AddBoolVarCache(&sGeoEnabled, "geo.enabled", sGeoEnabled);
|
||||
Preferences::AddBoolVarCache(&sGeoIgnoreLocationFilter, "geo.ignore.location_filter", sGeoIgnoreLocationFilter);
|
||||
|
||||
if (!sGeoEnabled) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -242,10 +242,6 @@ WEBIDL_FILES = [
|
|||
'PaintRequestList.webidl',
|
||||
'PannerNode.webidl',
|
||||
'ParentNode.webidl',
|
||||
'PeerConnectionImpl.webidl',
|
||||
'PeerConnectionImplEnums.webidl',
|
||||
'PeerConnectionObserver.webidl',
|
||||
'PeerConnectionObserverEnums.webidl',
|
||||
'Performance.webidl',
|
||||
'PerformanceNavigation.webidl',
|
||||
'PerformanceTiming.webidl',
|
||||
|
@ -444,6 +440,10 @@ if CONFIG['MOZ_WEBRTC']:
|
|||
WEBIDL_FILES += [
|
||||
'DataChannel.webidl',
|
||||
'MediaStreamList.webidl',
|
||||
'PeerConnectionImpl.webidl',
|
||||
'PeerConnectionImplEnums.webidl',
|
||||
'PeerConnectionObserver.webidl',
|
||||
'PeerConnectionObserverEnums.webidl',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WEBSPEECH']:
|
||||
|
|
|
@ -475,7 +475,10 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
|
|||
|
||||
// try to find an extant window with the given name
|
||||
nsCOMPtr<nsIDOMWindow> foundWindow;
|
||||
SafeGetWindowByName(name, aParent, getter_AddRefs(foundWindow));
|
||||
if (SafeGetWindowByName(name, aParent, getter_AddRefs(foundWindow)) ==
|
||||
NS_ERROR_DOM_INVALID_ACCESS_ERR) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
}
|
||||
GetWindowTreeItem(foundWindow, getter_AddRefs(newDocShellItem));
|
||||
|
||||
// no extant window? make a new one.
|
||||
|
@ -543,21 +546,26 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
|
|||
callerContextGuard.Push(cx);
|
||||
}
|
||||
|
||||
uint32_t activeDocsSandboxFlags = 0;
|
||||
if (!newDocShellItem) {
|
||||
// We're going to either open up a new window ourselves or ask a
|
||||
// nsIWindowProvider for one. In either case, we'll want to set the right
|
||||
// name on it.
|
||||
windowNeedsName = true;
|
||||
|
||||
// If the parent trying to open a new window is sandboxed,
|
||||
// this is not allowed and we fail here.
|
||||
// If the parent trying to open a new window is sandboxed
|
||||
// without 'allow-popups', this is not allowed and we fail here.
|
||||
if (aParent) {
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
aParent->GetDocument(getter_AddRefs(domdoc));
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
||||
|
||||
if (doc && (doc->GetSandboxFlags() & SANDBOXED_NAVIGATION)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
if (doc) {
|
||||
// Save sandbox flags for copying to new browsing context (docShell).
|
||||
activeDocsSandboxFlags = doc->GetSandboxFlags();
|
||||
if (activeDocsSandboxFlags & SANDBOXED_AUXILIARY_NAVIGATION) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -709,6 +717,16 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
|
|||
|
||||
nsCOMPtr<nsIDocShell> newDocShell(do_QueryInterface(newDocShellItem));
|
||||
NS_ENSURE_TRUE(newDocShell, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// Set up sandboxing attributes if the window is new.
|
||||
// The flags can only be non-zero for new windows.
|
||||
if (activeDocsSandboxFlags != 0) {
|
||||
newDocShell->SetSandboxFlags(activeDocsSandboxFlags);
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aParent);
|
||||
if (window) {
|
||||
newDocShell->SetOnePermittedSandboxedNavigator(window->GetDocShell());
|
||||
}
|
||||
}
|
||||
|
||||
rv = ReadyOpenedDocShellItem(newDocShellItem, aParent, windowIsNew, _retval);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -1299,6 +1317,7 @@ nsWindowWatcher::GetWindowByName(const PRUnichar *aTargetName,
|
|||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
nsresult rv;
|
||||
|
||||
*aResult = nullptr;
|
||||
|
||||
|
@ -1308,18 +1327,18 @@ nsWindowWatcher::GetWindowByName(const PRUnichar *aTargetName,
|
|||
GetWindowTreeItem(aCurrentWindow, getter_AddRefs(startItem));
|
||||
if (startItem) {
|
||||
// Note: original requestor is null here, per idl comments
|
||||
startItem->FindItemWithName(aTargetName, nullptr, nullptr,
|
||||
rv = startItem->FindItemWithName(aTargetName, nullptr, nullptr,
|
||||
getter_AddRefs(treeItem));
|
||||
}
|
||||
else {
|
||||
// Note: original requestor is null here, per idl comments
|
||||
FindItemWithName(aTargetName, nullptr, nullptr, getter_AddRefs(treeItem));
|
||||
rv = FindItemWithName(aTargetName, nullptr, nullptr, getter_AddRefs(treeItem));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(treeItem);
|
||||
domWindow.swap(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1731,6 +1750,7 @@ nsWindowWatcher::SafeGetWindowByName(const nsAString& aName,
|
|||
nsIDOMWindow** aResult)
|
||||
{
|
||||
*aResult = nullptr;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> startItem;
|
||||
GetWindowTreeItem(aCurrentWindow, getter_AddRefs(startItem));
|
||||
|
@ -1741,17 +1761,17 @@ nsWindowWatcher::SafeGetWindowByName(const nsAString& aName,
|
|||
|
||||
nsCOMPtr<nsIDocShellTreeItem> foundItem;
|
||||
if (startItem) {
|
||||
startItem->FindItemWithName(flatName.get(), nullptr, callerItem,
|
||||
rv = startItem->FindItemWithName(flatName.get(), nullptr, callerItem,
|
||||
getter_AddRefs(foundItem));
|
||||
}
|
||||
else {
|
||||
FindItemWithName(flatName.get(), nullptr, callerItem,
|
||||
rv = FindItemWithName(flatName.get(), nullptr, callerItem,
|
||||
getter_AddRefs(foundItem));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> foundWin = do_GetInterface(foundItem);
|
||||
foundWin.swap(*aResult);
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Fetch the nsIDOMWindow corresponding to the given nsIDocShellTreeItem.
|
||||
|
|
|
@ -214,20 +214,20 @@ gfxDWriteFontFamily::LocalizedName(nsAString &aLocalizedName)
|
|||
}
|
||||
|
||||
void
|
||||
gfxDWriteFontFamily::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxDWriteFontFamily::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
gfxFontFamily::SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
gfxFontFamily::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
// TODO:
|
||||
// This doesn't currently account for |mDWFamily|
|
||||
}
|
||||
|
||||
void
|
||||
gfxDWriteFontFamily::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxDWriteFontFamily::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -556,20 +556,20 @@ gfxDWriteFontEntry::IsCJKFont()
|
|||
}
|
||||
|
||||
void
|
||||
gfxDWriteFontEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxDWriteFontEntry::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
gfxFontEntry::SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
gfxFontEntry::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
// TODO:
|
||||
// This doesn't currently account for the |mFont| and |mFontFile| members
|
||||
}
|
||||
|
||||
void
|
||||
gfxDWriteFontEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxDWriteFontEntry::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1218,10 +1218,10 @@ gfxDWriteFontList::ResolveFontName(const nsAString& aFontName,
|
|||
}
|
||||
|
||||
void
|
||||
gfxDWriteFontList::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxDWriteFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
gfxPlatformFontList::SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
gfxPlatformFontList::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
|
||||
aSizes->mFontListSize +=
|
||||
mFontSubstitutes.SizeOfExcludingThis(SizeOfFamilyNameEntryExcludingThis,
|
||||
|
@ -1236,11 +1236,11 @@ gfxDWriteFontList::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
|||
}
|
||||
|
||||
void
|
||||
gfxDWriteFontList::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxDWriteFontList::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
static HRESULT GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName)
|
||||
|
|
|
@ -49,10 +49,10 @@ public:
|
|||
|
||||
void SetForceGDIClassic(bool aForce) { mForceGDIClassic = aForce; }
|
||||
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
|
||||
protected:
|
||||
/** This font family's directwrite fontfamily object */
|
||||
|
@ -153,10 +153,10 @@ public:
|
|||
void SetForceGDIClassic(bool aForce) { mForceGDIClassic = aForce; }
|
||||
bool GetForceGDIClassic() { return mForceGDIClassic; }
|
||||
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
|
||||
protected:
|
||||
friend class gfxDWriteFont;
|
||||
|
@ -366,10 +366,10 @@ public:
|
|||
|
||||
gfxFloat GetForceGDIClassicMaxFontSize() { return mForceGDIClassicMaxFontSize; }
|
||||
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
|
||||
private:
|
||||
friend class gfxDWriteFontFamily;
|
||||
|
|
|
@ -671,10 +671,10 @@ gfxDWriteFont::MeasureGlyphWidth(uint16_t aGlyph)
|
|||
}
|
||||
|
||||
void
|
||||
gfxDWriteFont::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxDWriteFont::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
gfxFont::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
aSizes->mFontInstances += aMallocSizeOf(mMetrics);
|
||||
if (mGlyphWidths) {
|
||||
aSizes->mFontInstances +=
|
||||
|
@ -683,11 +683,11 @@ gfxDWriteFont::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
|||
}
|
||||
|
||||
void
|
||||
gfxDWriteFont::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxDWriteFont::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontInstances += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
TemporaryRef<ScaledFont>
|
||||
|
|
|
@ -59,10 +59,10 @@ public:
|
|||
|
||||
virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions();
|
||||
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
|
||||
virtual FontType GetType() const { return FONT_TYPE_DWRITE; }
|
||||
|
||||
|
|
|
@ -538,20 +538,20 @@ FT2FontEntry::GetFontTable(uint32_t aTableTag)
|
|||
}
|
||||
|
||||
void
|
||||
FT2FontEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
FT2FontEntry::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
gfxFontEntry::SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
gfxFontEntry::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
aSizes->mFontListSize +=
|
||||
mFilename.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
||||
}
|
||||
|
||||
void
|
||||
FT2FontEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
FT2FontEntry::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -85,10 +85,10 @@ public:
|
|||
// accordingly so that we avoid using bad font tables
|
||||
void CheckForBrokenFont(gfxFontFamily *aFamily);
|
||||
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
|
||||
FT_Face mFTFace;
|
||||
cairo_font_face_t *mFontFace;
|
||||
|
|
|
@ -642,20 +642,20 @@ gfxFT2Font::FillGlyphDataForChar(uint32_t ch, CachedGlyphData *gd)
|
|||
}
|
||||
|
||||
void
|
||||
gfxFT2Font::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxFT2Font::AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
gfxFont::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
aSizes->mFontInstances +=
|
||||
mCharGlyphCache.SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
||||
}
|
||||
|
||||
void
|
||||
gfxFT2Font::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxFT2Font::AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontInstances += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
#ifdef USE_SKIA
|
||||
|
|
|
@ -62,10 +62,10 @@ public: // new functions
|
|||
return &entry->mData;
|
||||
}
|
||||
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
|
||||
#ifdef USE_SKIA
|
||||
virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions();
|
||||
|
|
|
@ -707,26 +707,22 @@ gfxFontEntry::CheckForGraphiteTables()
|
|||
/* static */ size_t
|
||||
gfxFontEntry::FontTableHashEntry::SizeOfEntryExcludingThis
|
||||
(FontTableHashEntry *aEntry,
|
||||
MallocSizeOf aMallocSizeOf,
|
||||
void* aUserArg)
|
||||
MallocSizeOf aMallocSizeOf,
|
||||
void* aUserArg)
|
||||
{
|
||||
FontListSizes *sizes = static_cast<FontListSizes*>(aUserArg);
|
||||
size_t n = 0;
|
||||
if (aEntry->mBlob) {
|
||||
sizes->mFontTableCacheSize += aMallocSizeOf(aEntry->mBlob);
|
||||
n += aMallocSizeOf(aEntry->mBlob);
|
||||
}
|
||||
if (aEntry->mSharedBlobData) {
|
||||
sizes->mFontTableCacheSize +=
|
||||
aEntry->mSharedBlobData->SizeOfIncludingThis(aMallocSizeOf);
|
||||
n += aEntry->mSharedBlobData->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
// the size of the table is recorded in the FontListSizes record,
|
||||
// so we return 0 here for the function result
|
||||
return 0;
|
||||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
gfxFontEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxFontEntry::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += mName.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
||||
|
||||
|
@ -739,16 +735,16 @@ gfxFontEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
|||
aSizes->mFontTableCacheSize +=
|
||||
mFontTableCache->SizeOfExcludingThis(
|
||||
FontTableHashEntry::SizeOfEntryExcludingThis,
|
||||
aMallocSizeOf, aSizes);
|
||||
aMallocSizeOf);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxFontEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxFontEntry::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1330,8 +1326,8 @@ gfxFontFamily::FindFont(const nsAString& aPostscriptName)
|
|||
}
|
||||
|
||||
void
|
||||
gfxFontFamily::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxFontFamily::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize +=
|
||||
mName.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
||||
|
@ -1343,19 +1339,19 @@ gfxFontFamily::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
|||
for (uint32_t i = 0; i < mAvailableFonts.Length(); ++i) {
|
||||
gfxFontEntry *fe = mAvailableFonts[i];
|
||||
if (fe) {
|
||||
fe->SizeOfIncludingThis(aMallocSizeOf, aSizes);
|
||||
fe->AddSizeOfIncludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxFontFamily::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxFontFamily::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* gfxFontCache - global cache of gfxFont instances.
|
||||
* Expires unused fonts after a short interval;
|
||||
|
@ -1382,8 +1378,8 @@ gfxFontCache::MemoryReporter::CollectReports
|
|||
{
|
||||
FontCacheSizes sizes;
|
||||
|
||||
gfxFontCache::GetCache()->SizeOfIncludingThis(&FontCacheMallocSizeOf,
|
||||
&sizes);
|
||||
gfxFontCache::GetCache()->AddSizeOfIncludingThis(&FontCacheMallocSizeOf,
|
||||
&sizes);
|
||||
|
||||
aCb->Callback(EmptyCString(),
|
||||
NS_LITERAL_CSTRING("explicit/gfx/font-cache"),
|
||||
|
@ -1596,35 +1592,36 @@ gfxFontCache::ClearCachedWordsForFont(HashEntry* aHashEntry, void* aUserData)
|
|||
|
||||
/*static*/
|
||||
size_t
|
||||
gfxFontCache::SizeOfFontEntryExcludingThis(HashEntry* aHashEntry,
|
||||
MallocSizeOf aMallocSizeOf,
|
||||
void* aUserArg)
|
||||
gfxFontCache::AddSizeOfFontEntryExcludingThis(HashEntry* aHashEntry,
|
||||
MallocSizeOf aMallocSizeOf,
|
||||
void* aUserArg)
|
||||
{
|
||||
HashEntry *entry = static_cast<HashEntry*>(aHashEntry);
|
||||
FontCacheSizes *sizes = static_cast<FontCacheSizes*>(aUserArg);
|
||||
entry->mFont->SizeOfExcludingThis(aMallocSizeOf, sizes);
|
||||
entry->mFont->AddSizeOfExcludingThis(aMallocSizeOf, sizes);
|
||||
|
||||
// The font records its size in the |sizes| parameter, so we return zero
|
||||
// The entry's size is recorded in the |sizes| parameter, so we return zero
|
||||
// here to the hashtable enumerator.
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
gfxFontCache::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxFontCache::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
// TODO: add the overhead of the expiration tracker (generation arrays)
|
||||
|
||||
mFonts.SizeOfExcludingThis(SizeOfFontEntryExcludingThis,
|
||||
aMallocSizeOf, aSizes);
|
||||
aSizes->mFontInstances +=
|
||||
mFonts.SizeOfExcludingThis(AddSizeOfFontEntryExcludingThis,
|
||||
aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
void
|
||||
gfxFontCache::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxFontCache::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontInstances += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
#define MAX_SSXX_VALUE 99
|
||||
|
@ -3833,8 +3830,8 @@ gfxFont::WordCacheEntrySizeOfExcludingThis(CacheHashEntry* aHashEntry,
|
|||
}
|
||||
|
||||
void
|
||||
gfxFont::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxFont::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
for (uint32_t i = 0; i < mGlyphExtentsArray.Length(); ++i) {
|
||||
aSizes->mFontInstances +=
|
||||
|
@ -3848,11 +3845,11 @@ gfxFont::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
|||
}
|
||||
|
||||
void
|
||||
gfxFont::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxFont::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontInstances += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -410,12 +410,12 @@ public:
|
|||
// Called to notify that aFont is being destroyed. Needed when we're tracking
|
||||
// the fonts belonging to this font entry.
|
||||
void NotifyFontDestroyed(gfxFont* aFont);
|
||||
|
||||
|
||||
// For memory reporting
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
|
||||
nsString mName;
|
||||
nsString mFamilyName;
|
||||
|
@ -615,8 +615,8 @@ private:
|
|||
|
||||
static size_t
|
||||
SizeOfEntryExcludingThis(FontTableHashEntry *aEntry,
|
||||
mozilla::MallocSizeOf aMallocSizeOf,
|
||||
void* aUserArg);
|
||||
mozilla::MallocSizeOf aMallocSizeOf,
|
||||
void* aUserArg);
|
||||
|
||||
private:
|
||||
static void DeleteFontTableBlobData(void *aBlobData);
|
||||
|
@ -776,10 +776,10 @@ public:
|
|||
void CheckForSimpleFamily();
|
||||
|
||||
// For memory reporter
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
|
||||
// Only used for debugging checks - does a linear search
|
||||
bool ContainsFace(gfxFontEntry* aFontEntry) {
|
||||
|
@ -944,10 +944,10 @@ public:
|
|||
mFonts.EnumerateEntries(ClearCachedWordsForFont, nullptr);
|
||||
}
|
||||
|
||||
void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
|
||||
protected:
|
||||
class MemoryReporter MOZ_FINAL
|
||||
|
@ -999,9 +999,9 @@ protected:
|
|||
gfxFont* mFont;
|
||||
};
|
||||
|
||||
static size_t SizeOfFontEntryExcludingThis(HashEntry* aHashEntry,
|
||||
mozilla::MallocSizeOf aMallocSizeOf,
|
||||
void* aUserArg);
|
||||
static size_t AddSizeOfFontEntryExcludingThis(HashEntry* aHashEntry,
|
||||
mozilla::MallocSizeOf aMallocSizeOf,
|
||||
void* aUserArg);
|
||||
|
||||
nsTHashtable<HashEntry> mFonts;
|
||||
|
||||
|
@ -1670,10 +1670,10 @@ public:
|
|||
// Glyph rendering/geometry has changed, so invalidate data as necessary.
|
||||
void NotifyGlyphsChanged();
|
||||
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
|
||||
typedef enum {
|
||||
FONT_TYPE_DWRITE,
|
||||
|
|
|
@ -565,10 +565,10 @@ gfxGDIFont::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID)
|
|||
}
|
||||
|
||||
void
|
||||
gfxGDIFont::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxGDIFont::AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
gfxFont::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
aSizes->mFontInstances += aMallocSizeOf(mMetrics);
|
||||
if (mGlyphWidths) {
|
||||
aSizes->mFontInstances +=
|
||||
|
@ -577,9 +577,9 @@ gfxGDIFont::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|||
}
|
||||
|
||||
void
|
||||
gfxGDIFont::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxGDIFont::AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontInstances += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
|
|
@ -54,10 +54,10 @@ public:
|
|||
// get hinted glyph width in pixels as 16.16 fixed-point value
|
||||
virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID);
|
||||
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
|
||||
virtual FontType GetType() const { return FONT_TYPE_GDI; }
|
||||
|
||||
|
|
|
@ -414,11 +414,11 @@ GDIFontEntry::CreateFontEntry(const nsAString& aName,
|
|||
}
|
||||
|
||||
void
|
||||
GDIFontEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
GDIFontEntry::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
|
@ -888,10 +888,10 @@ gfxGDIFontList::ResolveFontName(const nsAString& aFontName, nsAString& aResolved
|
|||
}
|
||||
|
||||
void
|
||||
gfxGDIFontList::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxGDIFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
gfxPlatformFontList::SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
gfxPlatformFontList::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
aSizes->mFontListSize +=
|
||||
mFontSubstitutes.SizeOfExcludingThis(SizeOfFamilyNameEntryExcludingThis,
|
||||
aMallocSizeOf);
|
||||
|
@ -904,9 +904,9 @@ gfxGDIFontList::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
|||
}
|
||||
|
||||
void
|
||||
gfxGDIFontList::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxGDIFontList::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
|
|
@ -240,8 +240,8 @@ public:
|
|||
|
||||
virtual bool TestCharacterMap(uint32_t aCh);
|
||||
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
|
||||
// create a font entry for a font with a given name
|
||||
static GDIFontEntry* CreateFontEntry(const nsAString& aName,
|
||||
|
@ -322,10 +322,10 @@ public:
|
|||
virtual bool ResolveFontName(const nsAString& aFontName,
|
||||
nsAString& aResolvedFontName);
|
||||
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
|
||||
private:
|
||||
friend class gfxWindowsPlatform;
|
||||
|
|
|
@ -419,18 +419,18 @@ gfxMacFont::GetScaledFont(DrawTarget *aTarget)
|
|||
}
|
||||
|
||||
void
|
||||
gfxMacFont::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxMacFont::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
gfxFont::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
// mCGFont is shared with the font entry, so not counted here;
|
||||
// and we don't have APIs to measure the cairo mFontFace object
|
||||
}
|
||||
|
||||
void
|
||||
gfxMacFont::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
gfxMacFont::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontInstances += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
|
|
@ -43,10 +43,10 @@ public:
|
|||
|
||||
virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> GetScaledFont(mozilla::gfx::DrawTarget *aTarget);
|
||||
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
|
||||
virtual FontType GetType() const { return FONT_TYPE_MAC; }
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ public:
|
|||
// use CGFontRef API to get direct access to system font data
|
||||
virtual hb_blob_t *GetFontTable(uint32_t aTag) MOZ_OVERRIDE;
|
||||
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
|
||||
nsresult ReadCMAP();
|
||||
|
||||
|
|
|
@ -426,11 +426,11 @@ MacOSFontEntry::HasFontTable(uint32_t aTableTag)
|
|||
}
|
||||
|
||||
void
|
||||
MacOSFontEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
MacOSFontEntry::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
/* gfxMacFontFamily */
|
||||
|
@ -773,40 +773,6 @@ gfxMacPlatformFontList::GetStandardFamilyName(const nsAString& aFontName, nsAStr
|
|||
return true;
|
||||
}
|
||||
|
||||
// Gecko 1.8 used Quickdraw font api's which produce a slightly different set of "family"
|
||||
// names. Try to resolve based on these names, in case this is stored in an old profile
|
||||
// 1.8: "Futura", "Futura Condensed" ==> 1.9: "Futura"
|
||||
|
||||
// convert the name to a Pascal-style Str255 to try as Quickdraw name
|
||||
Str255 qdname;
|
||||
NS_ConvertUTF16toUTF8 utf8name(aFontName);
|
||||
qdname[0] = std::max<size_t>(255, strlen(utf8name.get()));
|
||||
memcpy(&qdname[1], utf8name.get(), qdname[0]);
|
||||
|
||||
// look up the Quickdraw name
|
||||
ATSFontFamilyRef atsFamily = ::ATSFontFamilyFindFromQuickDrawName(qdname);
|
||||
if (atsFamily == (ATSFontFamilyRef)kInvalidFontFamily) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if we found a family, get its ATS name
|
||||
CFStringRef cfName;
|
||||
OSStatus status = ::ATSFontFamilyGetName(atsFamily, kATSOptionFlagsDefault, &cfName);
|
||||
if (status != noErr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// then use this to locate the family entry and retrieve its localized name
|
||||
nsAutoString familyName;
|
||||
GetStringForNSString((const NSString*)cfName, familyName);
|
||||
::CFRelease(cfName);
|
||||
|
||||
family = FindFamily(familyName);
|
||||
if (family) {
|
||||
family->LocalizedName(aFamilyName);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@ gfxPlatformFontList::MemoryReporter::CollectReports
|
|||
sizes.mFontTableCacheSize = 0;
|
||||
sizes.mCharMapsSize = 0;
|
||||
|
||||
gfxPlatformFontList::PlatformFontList()->SizeOfIncludingThis(&FontListMallocSizeOf,
|
||||
&sizes);
|
||||
gfxPlatformFontList::PlatformFontList()->AddSizeOfIncludingThis(&FontListMallocSizeOf,
|
||||
&sizes);
|
||||
|
||||
aCb->Callback(EmptyCString(),
|
||||
NS_LITERAL_CSTRING("explicit/gfx/font-list"),
|
||||
|
@ -763,7 +763,7 @@ SizeOfFamilyEntryExcludingThis(const nsAString& aKey,
|
|||
void* aUserArg)
|
||||
{
|
||||
FontListSizes *sizes = static_cast<FontListSizes*>(aUserArg);
|
||||
aFamily->SizeOfExcludingThis(aMallocSizeOf, sizes);
|
||||
aFamily->AddSizeOfExcludingThis(aMallocSizeOf, sizes);
|
||||
|
||||
sizes->mFontListSize += aKey.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
||||
|
||||
|
@ -833,8 +833,8 @@ SizeOfSharedCmapExcludingThis(CharMapHashKey* aHashEntry,
|
|||
}
|
||||
|
||||
void
|
||||
gfxPlatformFontList::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxPlatformFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize +=
|
||||
mFontFamilies.SizeOfExcludingThis(SizeOfFamilyEntryExcludingThis,
|
||||
|
@ -872,9 +872,9 @@ gfxPlatformFontList::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
|||
}
|
||||
|
||||
void
|
||||
gfxPlatformFontList::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
gfxPlatformFontList::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
|
|
@ -162,10 +162,10 @@ public:
|
|||
// (platforms may override, eg Mac)
|
||||
virtual bool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
|
||||
|
||||
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
|
||||
// search for existing cmap that matches the input
|
||||
// return the input if no match is found
|
||||
|
|
|
@ -557,7 +557,7 @@ JavaScriptParent::unwrap(JSContext *cx, ObjectId objId)
|
|||
{
|
||||
RootedObject obj(cx, findObject(objId));
|
||||
if (obj) {
|
||||
if (!JS_WrapObject(cx, obj.address()))
|
||||
if (!JS_WrapObject(cx, &obj))
|
||||
return nullptr;
|
||||
return obj;
|
||||
}
|
||||
|
|
|
@ -416,15 +416,16 @@ JavaScriptShared::toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
|
|||
}
|
||||
|
||||
bool
|
||||
CpowIdHolder::ToObject(JSContext *cx, JSObject **objp)
|
||||
CpowIdHolder::ToObject(JSContext *cx, JS::MutableHandleObject objp)
|
||||
{
|
||||
return js_->Unwrap(cx, cpows_, objp);
|
||||
}
|
||||
|
||||
bool
|
||||
JavaScriptShared::Unwrap(JSContext *cx, const InfallibleTArray<CpowEntry> &aCpows, JSObject **objp)
|
||||
JavaScriptShared::Unwrap(JSContext *cx, const InfallibleTArray<CpowEntry> &aCpows,
|
||||
JS::MutableHandleObject objp)
|
||||
{
|
||||
*objp = nullptr;
|
||||
objp.set(nullptr);
|
||||
|
||||
if (!aCpows.Length())
|
||||
return true;
|
||||
|
@ -454,7 +455,7 @@ JavaScriptShared::Unwrap(JSContext *cx, const InfallibleTArray<CpowEntry> &aCpow
|
|||
}
|
||||
}
|
||||
|
||||
*objp = obj;
|
||||
objp.set(obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class CpowIdHolder : public CpowHolder
|
|||
{
|
||||
}
|
||||
|
||||
bool ToObject(JSContext *cx, JSObject **objp);
|
||||
bool ToObject(JSContext *cx, JS::MutableHandleObject objp);
|
||||
|
||||
private:
|
||||
JavaScriptShared *js_;
|
||||
|
@ -87,7 +87,7 @@ class JavaScriptShared
|
|||
static const uint32_t OBJECT_EXTRA_BITS = 1;
|
||||
static const uint32_t OBJECT_IS_CALLABLE = (1 << 0);
|
||||
|
||||
bool Unwrap(JSContext *cx, const InfallibleTArray<CpowEntry> &aCpows, JSObject **objp);
|
||||
bool Unwrap(JSContext *cx, const InfallibleTArray<CpowEntry> &aCpows, JS::MutableHandleObject objp);
|
||||
bool Wrap(JSContext *cx, JS::HandleObject aObj, InfallibleTArray<CpowEntry> *outCpows);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "unicode/unum.h"
|
||||
#include "unicode/ustring.h"
|
||||
#endif
|
||||
#include "unicode/utypes.h"
|
||||
#include "vm/DateTime.h"
|
||||
#include "vm/GlobalObject.h"
|
||||
#include "vm/Interpreter.h"
|
||||
|
@ -963,7 +962,9 @@ intl_CompareStrings(JSContext *cx, UCollator *coll, HandleString str1, HandleStr
|
|||
if (!chars2)
|
||||
return false;
|
||||
|
||||
UCollationResult uresult = ucol_strcoll(coll, chars1, length1, chars2, length2);
|
||||
UCollationResult uresult = ucol_strcoll(coll, JSCharToUChar(chars1),
|
||||
length1, JSCharToUChar(chars2),
|
||||
length2);
|
||||
|
||||
int32_t res;
|
||||
switch (uresult) {
|
||||
|
@ -1305,7 +1306,7 @@ NewUNumberFormat(JSContext *cx, HandleObject numberFormat)
|
|||
currency = value.toString();
|
||||
MOZ_ASSERT(currency->length() == 3, "IsWellFormedCurrencyCode permits only length-3 strings");
|
||||
// uCurrency remains owned by currency.
|
||||
uCurrency = JS_GetStringCharsZ(cx, currency);
|
||||
uCurrency = JSCharToUChar(JS_GetStringCharsZ(cx, currency));
|
||||
if (!uCurrency)
|
||||
return nullptr;
|
||||
|
||||
|
@ -1412,13 +1413,14 @@ intl_FormatNumber(JSContext *cx, UNumberFormat *nf, double x, MutableHandleValue
|
|||
if (!chars.resize(INITIAL_STRING_BUFFER_SIZE))
|
||||
return false;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int size = unum_formatDouble(nf, x, chars.begin(), INITIAL_STRING_BUFFER_SIZE, nullptr,
|
||||
&status);
|
||||
int size = unum_formatDouble(nf, x, JSCharToUChar(chars.begin()),
|
||||
INITIAL_STRING_BUFFER_SIZE, nullptr, &status);
|
||||
if (status == U_BUFFER_OVERFLOW_ERROR) {
|
||||
if (!chars.resize(size))
|
||||
return false;
|
||||
status = U_ZERO_ERROR;
|
||||
unum_formatDouble(nf, x, chars.begin(), size, nullptr, &status);
|
||||
unum_formatDouble(nf, x, JSCharToUChar(chars.begin()),
|
||||
size, nullptr, &status);
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR);
|
||||
|
@ -1779,7 +1781,7 @@ js::intl_patternForSkeleton(JSContext *cx, unsigned argc, Value *vp)
|
|||
if (!skeleton)
|
||||
return false;
|
||||
SkipRoot skip(cx, &skeleton);
|
||||
uint32_t skeletonLen = u_strlen(skeleton);
|
||||
uint32_t skeletonLen = u_strlen(JSCharToUChar(skeleton));
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UDateTimePatternGenerator *gen = udatpg_open(icuLocale(locale.ptr()), &status);
|
||||
|
@ -1789,7 +1791,8 @@ js::intl_patternForSkeleton(JSContext *cx, unsigned argc, Value *vp)
|
|||
}
|
||||
ScopedICUObject<UDateTimePatternGenerator> toClose(gen, udatpg_close);
|
||||
|
||||
int32_t size = udatpg_getBestPattern(gen, skeleton, skeletonLen, nullptr, 0, &status);
|
||||
int32_t size = udatpg_getBestPattern(gen, JSCharToUChar(skeleton),
|
||||
skeletonLen, nullptr, 0, &status);
|
||||
if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR);
|
||||
return false;
|
||||
|
@ -1799,13 +1802,14 @@ js::intl_patternForSkeleton(JSContext *cx, unsigned argc, Value *vp)
|
|||
return false;
|
||||
pattern[size] = '\0';
|
||||
status = U_ZERO_ERROR;
|
||||
udatpg_getBestPattern(gen, skeleton, skeletonLen, pattern, size, &status);
|
||||
udatpg_getBestPattern(gen, JSCharToUChar(skeleton),
|
||||
skeletonLen, pattern, size, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedString str(cx, JS_NewUCStringCopyZ(cx, pattern));
|
||||
RootedString str(cx, JS_NewUCStringCopyZ(cx, reinterpret_cast<jschar*>(pattern.get())));
|
||||
if (!str)
|
||||
return false;
|
||||
args.rval().setString(str);
|
||||
|
@ -1853,7 +1857,7 @@ NewUDateFormat(JSContext *cx, HandleObject dateTimeFormat)
|
|||
if (!JSObject::getProperty(cx, internals, internals, cx->names().timeZone, &value))
|
||||
return nullptr;
|
||||
if (!value.isUndefined()) {
|
||||
uTimeZone = JS_GetStringCharsZ(cx, value.toString());
|
||||
uTimeZone = JSCharToUChar(JS_GetStringCharsZ(cx, value.toString()));
|
||||
if (!uTimeZone)
|
||||
return nullptr;
|
||||
uTimeZoneLength = u_strlen(uTimeZone);
|
||||
|
@ -1861,7 +1865,7 @@ NewUDateFormat(JSContext *cx, HandleObject dateTimeFormat)
|
|||
}
|
||||
if (!JSObject::getProperty(cx, internals, internals, cx->names().pattern, &value))
|
||||
return nullptr;
|
||||
uPattern = JS_GetStringCharsZ(cx, value.toString());
|
||||
uPattern = JSCharToUChar(JS_GetStringCharsZ(cx, value.toString()));
|
||||
if (!uPattern)
|
||||
return nullptr;
|
||||
uPatternLength = u_strlen(uPattern);
|
||||
|
@ -1900,12 +1904,12 @@ intl_FormatDateTime(JSContext *cx, UDateFormat *df, double x, MutableHandleValue
|
|||
if (!chars.resize(INITIAL_STRING_BUFFER_SIZE))
|
||||
return false;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int size = udat_format(df, x, chars.begin(), INITIAL_STRING_BUFFER_SIZE, nullptr, &status);
|
||||
int size = udat_format(df, x, JSCharToUChar(chars.begin()), INITIAL_STRING_BUFFER_SIZE, nullptr, &status);
|
||||
if (status == U_BUFFER_OVERFLOW_ERROR) {
|
||||
if (!chars.resize(size))
|
||||
return false;
|
||||
status = U_ZERO_ERROR;
|
||||
udat_format(df, x, chars.begin(), size, nullptr, &status);
|
||||
udat_format(df, x, JSCharToUChar(chars.begin()), size, nullptr, &status);
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define builtin_Intl_h
|
||||
|
||||
#include "NamespaceImports.h"
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/*
|
||||
* The Intl module specified by standard ECMA-402,
|
||||
|
@ -178,6 +179,21 @@ intl_patternForSkeleton(JSContext *cx, unsigned argc, Value *vp);
|
|||
extern bool
|
||||
intl_FormatDateTime(JSContext *cx, unsigned argc, Value *vp);
|
||||
|
||||
/**
|
||||
* Cast jschar* strings to UChar* strings used by ICU.
|
||||
*/
|
||||
inline const UChar *
|
||||
JSCharToUChar(const jschar *chars)
|
||||
{
|
||||
return reinterpret_cast<const UChar *>(chars);
|
||||
}
|
||||
|
||||
inline UChar *
|
||||
JSCharToUChar(jschar *chars)
|
||||
{
|
||||
return reinterpret_cast<UChar *>(chars);
|
||||
}
|
||||
|
||||
} // namespace js
|
||||
|
||||
#endif /* builtin_Intl_h */
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/NumericLimits.h"
|
||||
|
||||
#include <limits>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
|||
#include "ctypes/Library.h"
|
||||
|
||||
using namespace std;
|
||||
using mozilla::NumericLimits;
|
||||
|
||||
namespace js {
|
||||
namespace ctypes {
|
||||
|
@ -1423,7 +1424,7 @@ JS_STATIC_ASSERT(sizeof(long long) == 8);
|
|||
JS_STATIC_ASSERT(sizeof(size_t) == sizeof(uintptr_t));
|
||||
JS_STATIC_ASSERT(sizeof(float) == 4);
|
||||
JS_STATIC_ASSERT(sizeof(PRFuncPtr) == sizeof(void*));
|
||||
JS_STATIC_ASSERT(numeric_limits<double>::is_signed);
|
||||
JS_STATIC_ASSERT(NumericLimits<double>::is_signed);
|
||||
|
||||
// Templated helper to convert FromType to TargetType, for the default case
|
||||
// where the trivial POD constructor will do.
|
||||
|
@ -1488,15 +1489,15 @@ static JS_ALWAYS_INLINE bool IsAlwaysExact()
|
|||
// 2) If FromType is signed, TargetType must also be signed. (Floating point
|
||||
// types are always signed.)
|
||||
// 3) If TargetType is an exact integral type, FromType must be also.
|
||||
if (numeric_limits<TargetType>::digits < numeric_limits<FromType>::digits)
|
||||
if (NumericLimits<TargetType>::digits < NumericLimits<FromType>::digits)
|
||||
return false;
|
||||
|
||||
if (numeric_limits<FromType>::is_signed &&
|
||||
!numeric_limits<TargetType>::is_signed)
|
||||
if (NumericLimits<FromType>::is_signed &&
|
||||
!NumericLimits<TargetType>::is_signed)
|
||||
return false;
|
||||
|
||||
if (!numeric_limits<FromType>::is_exact &&
|
||||
numeric_limits<TargetType>::is_exact)
|
||||
if (!NumericLimits<FromType>::is_exact &&
|
||||
NumericLimits<TargetType>::is_exact)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -1507,7 +1508,7 @@ static JS_ALWAYS_INLINE bool IsAlwaysExact()
|
|||
template<class TargetType, class FromType, bool TargetSigned, bool FromSigned>
|
||||
struct IsExactImpl {
|
||||
static JS_ALWAYS_INLINE bool Test(FromType i, TargetType j) {
|
||||
JS_STATIC_ASSERT(numeric_limits<TargetType>::is_exact);
|
||||
JS_STATIC_ASSERT(NumericLimits<TargetType>::is_exact);
|
||||
return FromType(j) == i;
|
||||
}
|
||||
};
|
||||
|
@ -1516,7 +1517,7 @@ struct IsExactImpl {
|
|||
template<class TargetType, class FromType>
|
||||
struct IsExactImpl<TargetType, FromType, false, true> {
|
||||
static JS_ALWAYS_INLINE bool Test(FromType i, TargetType j) {
|
||||
JS_STATIC_ASSERT(numeric_limits<TargetType>::is_exact);
|
||||
JS_STATIC_ASSERT(NumericLimits<TargetType>::is_exact);
|
||||
return i >= 0 && FromType(j) == i;
|
||||
}
|
||||
};
|
||||
|
@ -1525,7 +1526,7 @@ struct IsExactImpl<TargetType, FromType, false, true> {
|
|||
template<class TargetType, class FromType>
|
||||
struct IsExactImpl<TargetType, FromType, true, false> {
|
||||
static JS_ALWAYS_INLINE bool Test(FromType i, TargetType j) {
|
||||
JS_STATIC_ASSERT(numeric_limits<TargetType>::is_exact);
|
||||
JS_STATIC_ASSERT(NumericLimits<TargetType>::is_exact);
|
||||
return TargetType(i) >= 0 && FromType(j) == i;
|
||||
}
|
||||
};
|
||||
|
@ -1536,7 +1537,7 @@ template<class TargetType, class FromType>
|
|||
static JS_ALWAYS_INLINE bool ConvertExact(FromType i, TargetType* result)
|
||||
{
|
||||
// Require that TargetType is integral, to simplify conversion.
|
||||
JS_STATIC_ASSERT(numeric_limits<TargetType>::is_exact);
|
||||
JS_STATIC_ASSERT(NumericLimits<TargetType>::is_exact);
|
||||
|
||||
*result = Convert<TargetType>(i);
|
||||
|
||||
|
@ -1547,8 +1548,8 @@ static JS_ALWAYS_INLINE bool ConvertExact(FromType i, TargetType* result)
|
|||
// Return 'true' if 'i' is exactly representable in 'TargetType'.
|
||||
return IsExactImpl<TargetType,
|
||||
FromType,
|
||||
numeric_limits<TargetType>::is_signed,
|
||||
numeric_limits<FromType>::is_signed>::Test(i, *result);
|
||||
NumericLimits<TargetType>::is_signed,
|
||||
NumericLimits<FromType>::is_signed>::Test(i, *result);
|
||||
}
|
||||
|
||||
// Templated helper to determine if Type 'i' is negative. Default case
|
||||
|
@ -1572,7 +1573,7 @@ struct IsNegativeImpl<Type, true> {
|
|||
template<class Type>
|
||||
static JS_ALWAYS_INLINE bool IsNegative(Type i)
|
||||
{
|
||||
return IsNegativeImpl<Type, numeric_limits<Type>::is_signed>::Test(i);
|
||||
return IsNegativeImpl<Type, NumericLimits<Type>::is_signed>::Test(i);
|
||||
}
|
||||
|
||||
// Implicitly convert val to bool, allowing bool, int, and double
|
||||
|
@ -1606,7 +1607,7 @@ template<class IntegerType>
|
|||
static bool
|
||||
jsvalToInteger(JSContext* cx, jsval val, IntegerType* result)
|
||||
{
|
||||
JS_STATIC_ASSERT(numeric_limits<IntegerType>::is_exact);
|
||||
JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
|
||||
|
||||
if (JSVAL_IS_INT(val)) {
|
||||
// Make sure the integer fits in the alotted precision, and has the right
|
||||
|
@ -1695,7 +1696,7 @@ template<class FloatType>
|
|||
static bool
|
||||
jsvalToFloat(JSContext *cx, jsval val, FloatType* result)
|
||||
{
|
||||
JS_STATIC_ASSERT(!numeric_limits<FloatType>::is_exact);
|
||||
JS_STATIC_ASSERT(!NumericLimits<FloatType>::is_exact);
|
||||
|
||||
// The following casts may silently throw away some bits, but there's
|
||||
// no good way around it. Sternly requiring that the 64-bit double
|
||||
|
@ -1751,7 +1752,7 @@ template<class IntegerType>
|
|||
static bool
|
||||
StringToInteger(JSContext* cx, JSString* string, IntegerType* result)
|
||||
{
|
||||
JS_STATIC_ASSERT(numeric_limits<IntegerType>::is_exact);
|
||||
JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
|
||||
|
||||
const jschar* cp = string->getChars(nullptr);
|
||||
if (!cp)
|
||||
|
@ -1763,7 +1764,7 @@ StringToInteger(JSContext* cx, JSString* string, IntegerType* result)
|
|||
|
||||
IntegerType sign = 1;
|
||||
if (cp[0] == '-') {
|
||||
if (!numeric_limits<IntegerType>::is_signed)
|
||||
if (!NumericLimits<IntegerType>::is_signed)
|
||||
return false;
|
||||
|
||||
sign = -1;
|
||||
|
@ -1811,7 +1812,7 @@ jsvalToBigInteger(JSContext* cx,
|
|||
bool allowString,
|
||||
IntegerType* result)
|
||||
{
|
||||
JS_STATIC_ASSERT(numeric_limits<IntegerType>::is_exact);
|
||||
JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
|
||||
|
||||
if (JSVAL_IS_INT(val)) {
|
||||
// Make sure the integer fits in the alotted precision, and has the right
|
||||
|
@ -1882,7 +1883,7 @@ jsidToBigInteger(JSContext* cx,
|
|||
bool allowString,
|
||||
IntegerType* result)
|
||||
{
|
||||
JS_STATIC_ASSERT(numeric_limits<IntegerType>::is_exact);
|
||||
JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
|
||||
|
||||
if (JSID_IS_INT(val)) {
|
||||
// Make sure the integer fits in the alotted precision, and has the right
|
||||
|
@ -1947,7 +1948,7 @@ template<class IntegerType>
|
|||
static bool
|
||||
jsvalToIntegerExplicit(jsval val, IntegerType* result)
|
||||
{
|
||||
JS_STATIC_ASSERT(numeric_limits<IntegerType>::is_exact);
|
||||
JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
|
||||
|
||||
if (JSVAL_IS_DOUBLE(val)) {
|
||||
// Convert -Inf, Inf, and NaN to 0; otherwise, convert by C-style cast.
|
||||
|
@ -2028,7 +2029,7 @@ template<class IntegerType, class CharType, size_t N, class AP>
|
|||
void
|
||||
IntegerToString(IntegerType i, int radix, Vector<CharType, N, AP>& result)
|
||||
{
|
||||
JS_STATIC_ASSERT(numeric_limits<IntegerType>::is_exact);
|
||||
JS_STATIC_ASSERT(NumericLimits<IntegerType>::is_exact);
|
||||
|
||||
// The buffer must be big enough for all the bits of IntegerType to fit,
|
||||
// in base-2, including '-'.
|
||||
|
@ -2112,7 +2113,7 @@ ConvertToJS(JSContext* cx,
|
|||
/* Return an Int64 or UInt64 object - do not convert to a JS number. */ \
|
||||
uint64_t value; \
|
||||
RootedObject proto(cx); \
|
||||
if (!numeric_limits<type>::is_signed) { \
|
||||
if (!NumericLimits<type>::is_signed) { \
|
||||
value = *static_cast<type*>(data); \
|
||||
/* Get ctypes.UInt64.prototype from ctypes.CType.prototype. */ \
|
||||
proto = CType::GetProtoFromType(cx, typeObj, SLOT_UINT64PROTO); \
|
||||
|
@ -2121,13 +2122,13 @@ ConvertToJS(JSContext* cx,
|
|||
} else { \
|
||||
value = int64_t(*static_cast<type*>(data)); \
|
||||
/* Get ctypes.Int64.prototype from ctypes.CType.prototype. */ \
|
||||
proto = CType::GetProtoFromType(cx, typeObj, SLOT_INT64PROTO); \
|
||||
proto = CType::GetProtoFromType(cx, typeObj, SLOT_INT64PROTO); \
|
||||
if (!proto) \
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
JSObject* obj = Int64Base::Construct(cx, proto, value, \
|
||||
!numeric_limits<type>::is_signed); \
|
||||
!NumericLimits<type>::is_signed); \
|
||||
if (!obj) \
|
||||
return false; \
|
||||
*result = OBJECT_TO_JSVAL(obj); \
|
||||
|
@ -2977,7 +2978,7 @@ BuildDataSource(JSContext* cx,
|
|||
#define DEFINE_WRAPPED_INT_TYPE(name, type, ffiType) \
|
||||
case TYPE_##name: \
|
||||
/* Serialize as a wrapped decimal integer. */ \
|
||||
if (!numeric_limits<type>::is_signed) \
|
||||
if (!NumericLimits<type>::is_signed) \
|
||||
AppendString(result, "ctypes.UInt64(\""); \
|
||||
else \
|
||||
AppendString(result, "ctypes.Int64(\""); \
|
||||
|
|
|
@ -3236,10 +3236,10 @@ EmitVariables(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn, VarEmit
|
|||
/*
|
||||
* Emit variable binding ops, but not destructuring ops. The
|
||||
* parser (see Parser::variables) has ensured that our caller
|
||||
* will be the PNK_FOR/PNK_FORIN case in EmitTree, and that
|
||||
* case will emit the destructuring code only after emitting an
|
||||
* enumerating opcode and a branch that tests whether the
|
||||
* enumeration ended.
|
||||
* will be the PNK_FOR/PNK_FORIN/PNK_FOROF case in EmitTree, and
|
||||
* that case will emit the destructuring code only after
|
||||
* emitting an enumerating opcode and a branch that tests
|
||||
* whether the enumeration ended.
|
||||
*/
|
||||
JS_ASSERT(emitOption == DefineVars);
|
||||
JS_ASSERT(pn->pn_count == 1);
|
||||
|
@ -4745,12 +4745,12 @@ EmitNormalFor(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn, ptrdiff
|
|||
static inline bool
|
||||
EmitFor(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn, ptrdiff_t top)
|
||||
{
|
||||
if (pn->pn_left->isKind(PNK_FORIN)) {
|
||||
// FIXME: Give for-of loops their own PNK. Bug 922066.
|
||||
if (pn->pn_iflags == JSITER_FOR_OF)
|
||||
return EmitForOf(cx, bce, pn, top);
|
||||
if (pn->pn_left->isKind(PNK_FORIN))
|
||||
return EmitForIn(cx, bce, pn, top);
|
||||
}
|
||||
|
||||
if (pn->pn_left->isKind(PNK_FOROF))
|
||||
return EmitForOf(cx, bce, pn, top);
|
||||
|
||||
JS_ASSERT(pn->pn_left->isKind(PNK_FORHEAD));
|
||||
return EmitNormalFor(cx, bce, pn, top);
|
||||
}
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче