2013-12-13 20:54:04 +04:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<bindings id="testBindings" xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:html="http://www.w3.org/1999/xhtml">
|
2014-08-12 07:06:55 +04:00
|
|
|
<binding id="testAllowScript" bindToUntrustedContent="true">
|
2013-12-13 20:54:04 +04:00
|
|
|
<implementation>
|
|
|
|
<property name="someProp" onget="return 2;" readonly="true"></property>
|
|
|
|
<method name="someMethod"><body> return 3; </body></method>
|
|
|
|
<method name="startTest">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// Make sure we only get constructed when we're loaded from a domain
|
|
|
|
// with script enabled.
|
|
|
|
is(this.id, 'allow', "XBL should only be bound when the origin of the binding allows scripts");
|
|
|
|
|
|
|
|
var t = this;
|
|
|
|
doFinish = function() {
|
|
|
|
// Take a moment to make sure that other constructors don't run when they shouldn't.
|
|
|
|
if (t.id == 'allow')
|
|
|
|
setTimeout(SpecialPowers.wrap(window.parent).finish, 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
onTestEvent = function(target) {
|
|
|
|
ok(true, 'called event handler');
|
|
|
|
|
2014-04-06 23:32:39 +04:00
|
|
|
// Try calling event handlers on anonymous content.
|
2013-12-13 20:54:04 +04:00
|
|
|
var e = new MouseEvent('click');
|
|
|
|
document.getAnonymousNodes(target)[1].dispatchEvent(e);
|
2014-04-06 23:32:39 +04:00
|
|
|
ok(window.calledEventHandlerOnAC, "Should invoke event handler on AC");
|
2013-12-13 20:54:04 +04:00
|
|
|
|
|
|
|
// Now, dispatch a key event to test key handlers and move the test along.
|
|
|
|
var k = document.createEvent('KeyboardEvent');
|
|
|
|
k.initEvent('keyup', true, true);
|
|
|
|
target.dispatchEvent(k);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check the implementation.
|
|
|
|
is(this.someProp, 2, "Properties work");
|
|
|
|
is(this.someMethod(), 3, "Methods work");
|
|
|
|
|
|
|
|
// Kick over to the event handlers. This tests XBL event handlers,
|
|
|
|
// XBL key handlers, and event handlers on anonymous content.
|
|
|
|
this.dispatchEvent(new CustomEvent('testEvent'));
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<constructor>
|
|
|
|
<![CDATA[
|
|
|
|
win = XPCNativeWrapper.unwrap(window);
|
|
|
|
SpecialPowers = win.SpecialPowers;
|
|
|
|
ok = win.ok = SpecialPowers.wrap(window.parent).ok;
|
|
|
|
is = win.is = SpecialPowers.wrap(window.parent).is;
|
|
|
|
info = win.info = SpecialPowers.wrap(window.parent).info;
|
|
|
|
|
|
|
|
info("Invoked constructor for " + this.id);
|
|
|
|
|
|
|
|
var t = this;
|
2017-01-25 09:01:52 +03:00
|
|
|
window.addEventListener('load', function() {
|
2013-12-13 20:54:04 +04:00
|
|
|
// Wait two refresh-driver ticks to make sure that the constructor runs
|
|
|
|
// for both |allow| and |deny| if it's ever going to.
|
|
|
|
//
|
|
|
|
// See bug 944407 comment 37.
|
|
|
|
info("Invoked load listener for " + t.id);
|
|
|
|
window.requestAnimationFrame(function() { window.requestAnimationFrame(t.startTest.bind(t)); });
|
2017-01-25 09:01:52 +03:00
|
|
|
}, {once: true});
|
2013-12-13 20:54:04 +04:00
|
|
|
]]>
|
|
|
|
</constructor>
|
|
|
|
</implementation>
|
|
|
|
<handlers>
|
|
|
|
<handler event="testEvent" action="onTestEvent(this)" allowuntrusted="true"/>
|
|
|
|
<handler event="keyup" action="ok(true, 'called key handler'); doFinish();" allowuntrusted="true"/>
|
|
|
|
</handlers>
|
2014-04-06 23:32:39 +04:00
|
|
|
<content>Anonymous Content<html:div onclick="window.calledEventHandlerOnAC = true;"></html:div><html:b style="display:none"><children/></html:b></content>
|
2013-12-13 20:54:04 +04:00
|
|
|
</binding>
|
|
|
|
</bindings>
|