mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
19391253d9
--HG-- rename : content/xbl/src/XBLChildrenElement.cpp => dom/xbl/XBLChildrenElement.cpp rename : content/xbl/src/XBLChildrenElement.h => dom/xbl/XBLChildrenElement.h rename : content/xbl/builtin/android/jar.mn => dom/xbl/builtin/android/jar.mn rename : content/xbl/builtin/android/moz.build => dom/xbl/builtin/android/moz.build rename : content/xbl/builtin/android/platformHTMLBindings.xml => dom/xbl/builtin/android/platformHTMLBindings.xml rename : content/xbl/builtin/browser-base.inc => dom/xbl/builtin/browser-base.inc rename : content/xbl/builtin/editor-base.inc => dom/xbl/builtin/editor-base.inc rename : content/xbl/builtin/emacs/jar.mn => dom/xbl/builtin/emacs/jar.mn rename : content/xbl/builtin/emacs/moz.build => dom/xbl/builtin/emacs/moz.build rename : content/xbl/builtin/emacs/platformHTMLBindings.xml => dom/xbl/builtin/emacs/platformHTMLBindings.xml rename : content/xbl/builtin/input-fields-base.inc => dom/xbl/builtin/input-fields-base.inc rename : content/xbl/builtin/mac/jar.mn => dom/xbl/builtin/mac/jar.mn rename : content/xbl/builtin/mac/moz.build => dom/xbl/builtin/mac/moz.build rename : content/xbl/builtin/mac/platformHTMLBindings.xml => dom/xbl/builtin/mac/platformHTMLBindings.xml rename : content/xbl/builtin/moz.build => dom/xbl/builtin/moz.build rename : content/xbl/builtin/textareas-base.inc => dom/xbl/builtin/textareas-base.inc rename : content/xbl/builtin/unix/jar.mn => dom/xbl/builtin/unix/jar.mn rename : content/xbl/builtin/unix/moz.build => dom/xbl/builtin/unix/moz.build rename : content/xbl/builtin/unix/platformHTMLBindings.xml => dom/xbl/builtin/unix/platformHTMLBindings.xml rename : content/xbl/builtin/win/jar.mn => dom/xbl/builtin/win/jar.mn rename : content/xbl/builtin/win/moz.build => dom/xbl/builtin/win/moz.build rename : content/xbl/builtin/win/platformHTMLBindings.xml => dom/xbl/builtin/win/platformHTMLBindings.xml rename : content/xbl/crashtests/205735-1.xhtml => dom/xbl/crashtests/205735-1.xhtml rename : content/xbl/crashtests/223799-1.xul => dom/xbl/crashtests/223799-1.xul rename : content/xbl/crashtests/226744-1.xhtml => dom/xbl/crashtests/226744-1.xhtml rename : content/xbl/crashtests/232095-1.xul => dom/xbl/crashtests/232095-1.xul rename : content/xbl/crashtests/277523-1.xhtml => dom/xbl/crashtests/277523-1.xhtml rename : content/xbl/crashtests/277950-1.xhtml => dom/xbl/crashtests/277950-1.xhtml rename : content/xbl/crashtests/336744-1-inner.html => dom/xbl/crashtests/336744-1-inner.html rename : content/xbl/crashtests/336744-1.html => dom/xbl/crashtests/336744-1.html rename : content/xbl/crashtests/336960-1-inner.xhtml => dom/xbl/crashtests/336960-1-inner.xhtml rename : content/xbl/crashtests/336960-1.html => dom/xbl/crashtests/336960-1.html rename : content/xbl/crashtests/342954-1.xhtml => dom/xbl/crashtests/342954-1.xhtml rename : content/xbl/crashtests/342954-2-xbl.xml => dom/xbl/crashtests/342954-2-xbl.xml rename : content/xbl/crashtests/342954-2.xhtml => dom/xbl/crashtests/342954-2.xhtml rename : content/xbl/crashtests/368276-1.xhtml => dom/xbl/crashtests/368276-1.xhtml rename : content/xbl/crashtests/368641-1.xhtml => dom/xbl/crashtests/368641-1.xhtml rename : content/xbl/crashtests/378521-1.xhtml => dom/xbl/crashtests/378521-1.xhtml rename : content/xbl/crashtests/382376-1.xhtml => dom/xbl/crashtests/382376-1.xhtml rename : content/xbl/crashtests/382376-2.xhtml => dom/xbl/crashtests/382376-2.xhtml rename : content/xbl/crashtests/397596-1.xhtml => dom/xbl/crashtests/397596-1.xhtml rename : content/xbl/crashtests/404125-1.xhtml => dom/xbl/crashtests/404125-1.xhtml rename : content/xbl/crashtests/406900-1.xul => dom/xbl/crashtests/406900-1.xul rename : content/xbl/crashtests/406904-1.xhtml => dom/xbl/crashtests/406904-1.xhtml rename : content/xbl/crashtests/406904-2.xhtml => dom/xbl/crashtests/406904-2.xhtml rename : content/xbl/crashtests/415192-1.xul => dom/xbl/crashtests/415192-1.xul rename : content/xbl/crashtests/415301-1.xul => dom/xbl/crashtests/415301-1.xul rename : content/xbl/crashtests/418133-1.xhtml => dom/xbl/crashtests/418133-1.xhtml rename : content/xbl/crashtests/420233-1.xhtml => dom/xbl/crashtests/420233-1.xhtml rename : content/xbl/crashtests/421997-1.xhtml => dom/xbl/crashtests/421997-1.xhtml rename : content/xbl/crashtests/432813-1-xbl.xml => dom/xbl/crashtests/432813-1-xbl.xml rename : content/xbl/crashtests/432813-1.xhtml => dom/xbl/crashtests/432813-1.xhtml rename : content/xbl/crashtests/454820-1.html => dom/xbl/crashtests/454820-1.html rename : content/xbl/crashtests/460665-1.xhtml => dom/xbl/crashtests/460665-1.xhtml rename : content/xbl/crashtests/463511-1.xhtml => dom/xbl/crashtests/463511-1.xhtml rename : content/xbl/crashtests/464863-1.xhtml => dom/xbl/crashtests/464863-1.xhtml rename : content/xbl/crashtests/472260-1.xhtml => dom/xbl/crashtests/472260-1.xhtml rename : content/xbl/crashtests/477878-1.html => dom/xbl/crashtests/477878-1.html rename : content/xbl/crashtests/492978-1.xul => dom/xbl/crashtests/492978-1.xul rename : content/xbl/crashtests/493123-1.xhtml => dom/xbl/crashtests/493123-1.xhtml rename : content/xbl/crashtests/495354-1.xhtml => dom/xbl/crashtests/495354-1.xhtml rename : content/xbl/crashtests/507628-1.xhtml => dom/xbl/crashtests/507628-1.xhtml rename : content/xbl/crashtests/507991-1.xhtml => dom/xbl/crashtests/507991-1.xhtml rename : content/xbl/crashtests/830614-1.xul => dom/xbl/crashtests/830614-1.xul rename : content/xbl/crashtests/895805-1.xhtml => dom/xbl/crashtests/895805-1.xhtml rename : content/xbl/crashtests/crashtests.list => dom/xbl/crashtests/crashtests.list rename : content/xbl/crashtests/set-field-bad-this.xhtml => dom/xbl/crashtests/set-field-bad-this.xhtml rename : content/xbl/src/moz.build => dom/xbl/moz.build rename : content/xbl/src/nsBindingManager.cpp => dom/xbl/nsBindingManager.cpp rename : content/xbl/src/nsBindingManager.h => dom/xbl/nsBindingManager.h rename : content/xbl/src/nsXBLBinding.cpp => dom/xbl/nsXBLBinding.cpp rename : content/xbl/src/nsXBLBinding.h => dom/xbl/nsXBLBinding.h rename : content/xbl/src/nsXBLContentSink.cpp => dom/xbl/nsXBLContentSink.cpp rename : content/xbl/src/nsXBLContentSink.h => dom/xbl/nsXBLContentSink.h rename : content/xbl/src/nsXBLDocumentInfo.cpp => dom/xbl/nsXBLDocumentInfo.cpp rename : content/xbl/src/nsXBLDocumentInfo.h => dom/xbl/nsXBLDocumentInfo.h rename : content/xbl/src/nsXBLEventHandler.cpp => dom/xbl/nsXBLEventHandler.cpp rename : content/xbl/src/nsXBLEventHandler.h => dom/xbl/nsXBLEventHandler.h rename : content/xbl/src/nsXBLMaybeCompiled.h => dom/xbl/nsXBLMaybeCompiled.h rename : content/xbl/src/nsXBLProtoImpl.cpp => dom/xbl/nsXBLProtoImpl.cpp rename : content/xbl/src/nsXBLProtoImpl.h => dom/xbl/nsXBLProtoImpl.h rename : content/xbl/src/nsXBLProtoImplField.cpp => dom/xbl/nsXBLProtoImplField.cpp rename : content/xbl/src/nsXBLProtoImplField.h => dom/xbl/nsXBLProtoImplField.h rename : content/xbl/src/nsXBLProtoImplMember.h => dom/xbl/nsXBLProtoImplMember.h rename : content/xbl/src/nsXBLProtoImplMethod.cpp => dom/xbl/nsXBLProtoImplMethod.cpp rename : content/xbl/src/nsXBLProtoImplMethod.h => dom/xbl/nsXBLProtoImplMethod.h rename : content/xbl/src/nsXBLProtoImplProperty.cpp => dom/xbl/nsXBLProtoImplProperty.cpp rename : content/xbl/src/nsXBLProtoImplProperty.h => dom/xbl/nsXBLProtoImplProperty.h rename : content/xbl/src/nsXBLPrototypeBinding.cpp => dom/xbl/nsXBLPrototypeBinding.cpp rename : content/xbl/src/nsXBLPrototypeBinding.h => dom/xbl/nsXBLPrototypeBinding.h rename : content/xbl/src/nsXBLPrototypeHandler.cpp => dom/xbl/nsXBLPrototypeHandler.cpp rename : content/xbl/src/nsXBLPrototypeHandler.h => dom/xbl/nsXBLPrototypeHandler.h rename : content/xbl/src/nsXBLPrototypeResources.cpp => dom/xbl/nsXBLPrototypeResources.cpp rename : content/xbl/src/nsXBLPrototypeResources.h => dom/xbl/nsXBLPrototypeResources.h rename : content/xbl/src/nsXBLResourceLoader.cpp => dom/xbl/nsXBLResourceLoader.cpp rename : content/xbl/src/nsXBLResourceLoader.h => dom/xbl/nsXBLResourceLoader.h rename : content/xbl/src/nsXBLSerialize.cpp => dom/xbl/nsXBLSerialize.cpp rename : content/xbl/src/nsXBLSerialize.h => dom/xbl/nsXBLSerialize.h rename : content/xbl/src/nsXBLService.cpp => dom/xbl/nsXBLService.cpp rename : content/xbl/src/nsXBLService.h => dom/xbl/nsXBLService.h rename : content/xbl/src/nsXBLWindowKeyHandler.cpp => dom/xbl/nsXBLWindowKeyHandler.cpp rename : content/xbl/src/nsXBLWindowKeyHandler.h => dom/xbl/nsXBLWindowKeyHandler.h rename : content/xbl/test/bug310107-resource.xhtml => dom/xbl/test/bug310107-resource.xhtml rename : content/xbl/test/chrome.ini => dom/xbl/test/chrome.ini rename : content/xbl/test/file_bug372769.xhtml => dom/xbl/test/file_bug372769.xhtml rename : content/xbl/test/file_bug379959_cross.html => dom/xbl/test/file_bug379959_cross.html rename : content/xbl/test/file_bug379959_data.html => dom/xbl/test/file_bug379959_data.html rename : content/xbl/test/file_bug379959_xbl.xml => dom/xbl/test/file_bug379959_xbl.xml rename : content/xbl/test/file_bug397934.xhtml => dom/xbl/test/file_bug397934.xhtml rename : content/xbl/test/file_bug481558.xbl => dom/xbl/test/file_bug481558.xbl rename : content/xbl/test/file_bug481558css.sjs => dom/xbl/test/file_bug481558css.sjs rename : content/xbl/test/file_bug591198_inner.html => dom/xbl/test/file_bug591198_inner.html rename : content/xbl/test/file_bug591198_xbl.xml => dom/xbl/test/file_bug591198_xbl.xml rename : content/xbl/test/file_bug821850.xhtml => dom/xbl/test/file_bug821850.xhtml rename : content/xbl/test/file_bug844783.xhtml => dom/xbl/test/file_bug844783.xhtml rename : content/xbl/test/file_bug944407.html => dom/xbl/test/file_bug944407.html rename : content/xbl/test/file_bug944407.xml => dom/xbl/test/file_bug944407.xml rename : content/xbl/test/file_bug950909.html => dom/xbl/test/file_bug950909.html rename : content/xbl/test/file_bug950909.xml => dom/xbl/test/file_bug950909.xml rename : content/xbl/test/mochitest.ini => dom/xbl/test/mochitest.ini rename : content/xbl/test/moz.build => dom/xbl/test/moz.build rename : content/xbl/test/test_bug310107.html => dom/xbl/test/test_bug310107.html rename : content/xbl/test/test_bug366770.html => dom/xbl/test/test_bug366770.html rename : content/xbl/test/test_bug371724.xhtml => dom/xbl/test/test_bug371724.xhtml rename : content/xbl/test/test_bug372769.html => dom/xbl/test/test_bug372769.html rename : content/xbl/test/test_bug378518.xul => dom/xbl/test/test_bug378518.xul rename : content/xbl/test/test_bug378866.xhtml => dom/xbl/test/test_bug378866.xhtml rename : content/xbl/test/test_bug379959.html => dom/xbl/test/test_bug379959.html rename : content/xbl/test/test_bug389322.xhtml => dom/xbl/test/test_bug389322.xhtml rename : content/xbl/test/test_bug397934.html => dom/xbl/test/test_bug397934.html rename : content/xbl/test/test_bug398135.xul => dom/xbl/test/test_bug398135.xul rename : content/xbl/test/test_bug398492.xul => dom/xbl/test/test_bug398492.xul rename : content/xbl/test/test_bug400705.xhtml => dom/xbl/test/test_bug400705.xhtml rename : content/xbl/test/test_bug401907.xhtml => dom/xbl/test/test_bug401907.xhtml rename : content/xbl/test/test_bug403162.xhtml => dom/xbl/test/test_bug403162.xhtml rename : content/xbl/test/test_bug468210.xhtml => dom/xbl/test/test_bug468210.xhtml rename : content/xbl/test/test_bug481558.html => dom/xbl/test/test_bug481558.html rename : content/xbl/test/test_bug526178.xhtml => dom/xbl/test/test_bug526178.xhtml rename : content/xbl/test/test_bug542406.xhtml => dom/xbl/test/test_bug542406.xhtml rename : content/xbl/test/test_bug591198.html => dom/xbl/test/test_bug591198.html rename : content/xbl/test/test_bug639338.xhtml => dom/xbl/test/test_bug639338.xhtml rename : content/xbl/test/test_bug721452.xul => dom/xbl/test/test_bug721452.xul rename : content/xbl/test/test_bug723676.xul => dom/xbl/test/test_bug723676.xul rename : content/xbl/test/test_bug772966.xul => dom/xbl/test/test_bug772966.xul rename : content/xbl/test/test_bug790265.xhtml => dom/xbl/test/test_bug790265.xhtml rename : content/xbl/test/test_bug821850.html => dom/xbl/test/test_bug821850.html rename : content/xbl/test/test_bug844783.html => dom/xbl/test/test_bug844783.html rename : content/xbl/test/test_bug944407.xul => dom/xbl/test/test_bug944407.xul rename : content/xbl/test/test_bug950909.xul => dom/xbl/test/test_bug950909.xul extra : rebase_source : 44ab05088f70826c70dee3af30221e628ec1e4e8
299 lines
13 KiB
HTML
299 lines
13 KiB
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=821850
|
|
-->
|
|
<head>
|
|
<bindings xmlns="http://www.mozilla.org/xbl">
|
|
<binding id="testBinding">
|
|
<implementation>
|
|
<constructor>
|
|
// Store a property as an expando on the bound element.
|
|
this._prop = "propVal";
|
|
|
|
// Wait for both constructors to fire.
|
|
window.constructorCount = (window.constructorCount + 1) || 1;
|
|
if (window.constructorCount != 2)
|
|
return;
|
|
|
|
// Grab some basic infrastructure off the content window.
|
|
var win = XPCNativeWrapper.unwrap(window);
|
|
SpecialPowers = win.SpecialPowers;
|
|
Cu = SpecialPowers.Cu;
|
|
is = win.is;
|
|
ok = win.ok;
|
|
SimpleTest = win.SimpleTest;
|
|
|
|
// Stick some expandos on the content window.
|
|
window.xrayExpando = 3;
|
|
win.primitiveExpando = 11;
|
|
win.stringExpando = "stringExpando";
|
|
win.objectExpando = { foo: 12 };
|
|
win.globalExpando = SpecialPowers.unwrap(Cu.getGlobalForObject({}));
|
|
win.functionExpando = function() { return "called" };
|
|
win.functionExpando.prop = 2;
|
|
|
|
// Make sure we're Xraying.
|
|
ok(Cu.isXrayWrapper(window), "Window is Xrayed");
|
|
ok(Cu.isXrayWrapper(document), "Document is Xrayed");
|
|
|
|
var bound = document.getElementById('bound');
|
|
ok(bound, "bound is non-null");
|
|
is(bound.method('baz'), "method:baz", "Xray methods work");
|
|
is(bound.prop, "propVal", "Property Xrays work");
|
|
is(bound.primitiveField, undefined, "Xrays don't show fields");
|
|
is(bound.wrappedJSObject.primitiveField, 2, "Waiving Xrays show fields");
|
|
|
|
// Check exposure behavior.
|
|
is(typeof bound.unexposedMethod, 'function',
|
|
"Unexposed method should be visible to XBL");
|
|
is(typeof bound.wrappedJSObject.unexposedMethod, 'undefined',
|
|
"Unexposed method should not be defined in content");
|
|
is(typeof bound.unexposedProperty, 'number',
|
|
"Unexposed property should be visible to XBL");
|
|
is(typeof bound.wrappedJSObject.unexposedProperty, 'undefined',
|
|
"Unexposed property should not be defined in content");
|
|
|
|
// Check that here document.QueryInterface works
|
|
ok("QueryInterface" in document,
|
|
"Should have a document.QueryInterface here");
|
|
is(document.QueryInterface(Components.interfaces.nsIDOMDocument),
|
|
document, "Should be able to QI the document");
|
|
|
|
// This gets invoked by an event handler.
|
|
window.finish = function() {
|
|
// Content messed with stuff. Make sure we still see the right thing.
|
|
is(bound.method('bay'), "method:bay", "Xray methods work");
|
|
is(bound.wrappedJSObject.method('bay'), "hah", "Xray waived methods work");
|
|
is(bound.prop, "set:someOtherVal", "Xray props work");
|
|
is(bound.wrappedJSObject.prop, "redefined", "Xray waived props work");
|
|
is(bound.wrappedJSObject.primitiveField, 321, "Can't do anything about redefined fields");
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
// Hand things off to content. Content will call us back.
|
|
win.go();
|
|
</constructor>
|
|
<field name="primitiveField">2</field>
|
|
<method name="unexposedMethod"><body></body></method>
|
|
<property name="unexposedProperty" onget="return 2;" readonly="true"></property>
|
|
<method name="method" exposeToUntrustedContent="true">
|
|
<parameter name="arg" />
|
|
<body>
|
|
return "method:" + arg;
|
|
</body>
|
|
</method>
|
|
<method name="passMeAJSObject" exposeToUntrustedContent="true">
|
|
<parameter name="arg" />
|
|
<body>
|
|
is(typeof arg.prop, 'undefined', "No properties");
|
|
is(Object.getOwnPropertyNames(arg).length, 0, "Should have no own properties");
|
|
try {
|
|
arg.foo = 2;
|
|
ok(true, "Stuff fails silently");
|
|
} catch (e) {
|
|
ok(false, "Stuff should fail silently");
|
|
}
|
|
is(typeof arg.foo, 'undefined', "Shouldn't place props");
|
|
</body>
|
|
</method>
|
|
<property name="prop" exposeToUntrustedContent="true">
|
|
<getter>return this._prop;</getter>
|
|
<setter>this._prop = "set:" + val;</setter>
|
|
</property>
|
|
</implementation>
|
|
<handlers>
|
|
<handler event="testevent" action="ok(true, 'called event handler'); finish();" allowuntrusted="true"/>
|
|
<handler event="testtrusted" action="ok(true, 'called trusted handler'); window.wrappedJSObject.triggeredTrustedHandler = true;"/>
|
|
<handler event="keyup" action="ok(true, 'called untrusted key handler'); window.wrappedJSObject.triggeredUntrustedKeyHandler = true;" allowuntrusted="true"/>
|
|
<handler event="keydown" action="ok(true, 'called trusted key handler'); window.wrappedJSObject.triggeredTrustedKeyHandler = true;"/>
|
|
</handlers>
|
|
</binding>
|
|
</bindings>
|
|
<script type="application/javascript">
|
|
<![CDATA[
|
|
|
|
ok = parent.ok;
|
|
is = parent.is;
|
|
SimpleTest = parent.SimpleTest;
|
|
SpecialPowers = parent.SpecialPowers;
|
|
|
|
// Test the Xray waiving behavior when accessing fields. We should be able to
|
|
// see sequential JS-implemented properties, but should regain Xrays when we
|
|
// hit a native property.
|
|
window.contentVal = { foo: 10, rabbit: { hole: { bar: 100, win: window} } };
|
|
ok(true, "Set contentVal");
|
|
|
|
// Check that we're not exposing QueryInterface to non-XBL code
|
|
ok(!("QueryInterface" in document),
|
|
"Should not have a document.QueryInterface here");
|
|
|
|
function go() {
|
|
"use strict";
|
|
|
|
// Test what we can and cannot access in the XBL scope.
|
|
is(typeof window.xrayExpando, "undefined", "Xray expandos are private to the caller");
|
|
is(window.primitiveExpando, 11, "Can see waived expandos");
|
|
is(window.stringExpando, "stringExpando", "Can see waived expandos");
|
|
is(typeof window.objectExpando, "object", "object expando exists");
|
|
checkThrows(function() window.objectExpando.foo);
|
|
is(SpecialPowers.wrap(window.objectExpando).foo, 12, "SpecialPowers sees the right thing");
|
|
is(typeof window.globalExpando, "object", "Can see global object");
|
|
checkThrows(function() window.globalExpando.win);
|
|
is(window.functionExpando(), "called", "XBL functions are callable");
|
|
checkThrows(function() window.functionExpando.prop);
|
|
|
|
// Inspect the bound element.
|
|
var bound = document.getElementById('bound');
|
|
is(bound.primitiveField, 2, "Can see primitive fields");
|
|
is(bound.method("foo"), "method:foo", "Can invoke XBL method from content");
|
|
is(bound.prop, "propVal", "Can access properties from content");
|
|
bound.prop = "someOtherVal";
|
|
is(bound.prop, "set:someOtherVal", "Can set properties from content");
|
|
|
|
// Make sure we can't pass JS objects to the XBL scope.
|
|
var proto = bound.__proto__;
|
|
proto.passMeAJSObject({prop: 2});
|
|
|
|
//
|
|
// Try sticking a bunch of stuff on the prototype object.
|
|
//
|
|
|
|
proto.someExpando = 201;
|
|
is(bound.someExpando, 201, "Can stick non-XBL properties on the proto");
|
|
|
|
// Previously, this code checked that content couldn't tamper with its XBL
|
|
// prototype. But we decided to allow this to reduce regression risk, so for
|
|
// now just check that this works.
|
|
function checkMayTamper(obj, propName, desc) {
|
|
var accessor = !('value' in Object.getOwnPropertyDescriptor(obj, propName));
|
|
if (!accessor)
|
|
checkAllowed(function() { obj[propName] = function() {} }, desc + ": assign");
|
|
checkAllowed(function() { Object.defineProperty(obj, propName, {configurable: true, value: 3}) }, desc + ": define with value");
|
|
checkAllowed(function() { Object.defineProperty(obj, propName, {configurable: true, writable: true}) }, desc + ": make writable");
|
|
checkAllowed(function() { Object.defineProperty(obj, propName, {configurable: true}) }, desc + ": make configurable");
|
|
checkAllowed(function() { Object.defineProperty(obj, propName, {configurable: true, get: function() {}}) }, desc + ": define with getter");
|
|
checkAllowed(function() { Object.defineProperty(obj, propName, {configurable: true, set: function() {}}) }, desc + ": define with setter");
|
|
|
|
// Windows are implemented as proxies, and Proxy::delete_ doesn't currently
|
|
// pass strict around. Work around it in the window.binding case by just
|
|
// checking if delete returns false.
|
|
// manually.
|
|
checkAllowed(function() { delete obj[propName]; }, desc + ": delete");
|
|
|
|
if (!accessor)
|
|
checkAllowed(function() { obj[propName] = function() {} }, desc + ": assign (again)");
|
|
}
|
|
|
|
// Make sure content can do whatever it wants with the prototype.
|
|
checkMayTamper(proto, 'method', "XBL Proto Method");
|
|
checkMayTamper(proto, 'prop', "XBL Proto Prop");
|
|
checkMayTamper(proto, 'primitiveField', "XBL Field Accessor");
|
|
|
|
// As above, check that content can do what it wants with the prototype's
|
|
// property on the global.
|
|
var protoName, count = 0;
|
|
for (var k of Object.getOwnPropertyNames(window)) {
|
|
if (!/testBinding/.exec(k))
|
|
continue;
|
|
count++;
|
|
protoName = k;
|
|
}
|
|
is(count, 1, "Should be exactly one prototype object");
|
|
checkMayTamper(window, protoName, "XBL prototype prop on window");
|
|
|
|
// Tamper with the derived object. This doesn't affect the XBL scope thanks
|
|
// to Xrays.
|
|
bound.method = function() { return "heh"; };
|
|
Object.defineProperty(bound, 'method', {value: function() { return "hah" }});
|
|
Object.defineProperty(bound, 'prop', {value: "redefined"});
|
|
bound.primitiveField = 321;
|
|
|
|
// We need a chrome window to create trusted events. This isn't really doable
|
|
// in child processes, so let's just skip if that's the case.
|
|
if (SpecialPowers.isMainProcess()) {
|
|
var Ci = SpecialPowers.Ci;
|
|
var chromeWin = SpecialPowers.wrap(window.top)
|
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
.getInterface(Ci.nsIWebNavigation)
|
|
.QueryInterface(Ci.nsIDocShell)
|
|
.chromeEventHandler.ownerDocument.defaultView;
|
|
|
|
// Untrusted events should not trigger event handlers without
|
|
// exposeToUntrustedContent=true.
|
|
window.triggeredTrustedHandler = false;
|
|
var untrustedEvent = new CustomEvent('testtrusted');
|
|
ok(!untrustedEvent.isTrusted, "Created an untrusted event");
|
|
bound.dispatchEvent(untrustedEvent);
|
|
ok(!window.triggeredTrustedHandler, "untrusted events should not trigger trusted handler");
|
|
var trustedEvent = new chromeWin.CustomEvent('testtrusted');
|
|
ok(trustedEvent.isTrusted, "Created a trusted event");
|
|
SpecialPowers.wrap(bound).dispatchEvent(trustedEvent);
|
|
ok(window.triggeredTrustedHandler, "trusted events should trigger trusted handler");
|
|
|
|
//
|
|
// We check key events as well, since they're implemented differently.
|
|
//
|
|
// NB: We don't check isTrusted on the events we create here, because
|
|
// according to smaug, old-style event initialization doesn't mark the
|
|
// event as trusted until it's dispatched.
|
|
//
|
|
|
|
window.triggeredUntrustedKeyHandler = false;
|
|
window.triggeredTrustedKeyHandler = false;
|
|
|
|
// Untrusted event, permissive handler.
|
|
var untrustedKeyEvent = document.createEvent('KeyboardEvent');
|
|
untrustedKeyEvent.initEvent('keyup', true, true);
|
|
bound.dispatchEvent(untrustedKeyEvent);
|
|
ok(window.triggeredUntrustedKeyHandler, "untrusted key events should trigger untrusted handler");
|
|
|
|
// Untrusted event, strict handler.
|
|
var fakeTrustedKeyEvent = document.createEvent('KeyboardEvent');
|
|
fakeTrustedKeyEvent.initEvent('keydown', true, true);
|
|
bound.dispatchEvent(fakeTrustedKeyEvent);
|
|
ok(!window.triggeredTrustedKeyHandler, "untrusted key events should not trigger trusted handler");
|
|
|
|
// Trusted event, strict handler.
|
|
var trustedKeyEvent = chromeWin.document.createEvent('KeyboardEvent');
|
|
trustedKeyEvent.initEvent('keydown', true, true);
|
|
SpecialPowers.wrap(bound).dispatchEvent(trustedKeyEvent);
|
|
ok(window.triggeredTrustedKeyHandler, "trusted key events should trigger trusted handler");
|
|
}
|
|
|
|
// Hand control back to the XBL scope by dispatching an event on the bound element.
|
|
bound.dispatchEvent(new CustomEvent('testevent'));
|
|
}
|
|
|
|
function checkThrows(fn) {
|
|
try { fn(); ok(false, "Should have thrown"); }
|
|
catch (e) { ok(!!/denied|insecure/.exec(e), "Should have thrown security exception: " + e); }
|
|
}
|
|
|
|
function checkAllowed(fn, desc) {
|
|
try { fn(); ok(true, desc + ": Didn't throw"); }
|
|
catch (e) { ok(false, desc + ": Threw: " + e); }
|
|
}
|
|
|
|
function setup() {
|
|
// When the bindings are applied, the constructor will be invoked and the
|
|
// test will continue.
|
|
document.getElementById('bound').style.MozBinding = 'url(#testBinding)';
|
|
document.getElementById('bound2').style.MozBinding = 'url(#testBinding)';
|
|
}
|
|
|
|
]]>
|
|
</script>
|
|
</head>
|
|
<body onload="setup()">
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=821850">Mozilla Bug 821850</a>
|
|
<p id="display"></p>
|
|
<div id="content">
|
|
<div id="bound">Bound element</div>
|
|
<div id="bound2">Bound element</div>
|
|
</div>
|
|
<pre id="test">
|
|
</pre>
|
|
</body>
|
|
</html>
|