Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <bindings id="testBindings" xmlns="http://www.mozilla.org/xbl" |
michael@0 | 3 | xmlns:html="http://www.w3.org/1999/xhtml"> |
michael@0 | 4 | <binding id="testAllowScript"> |
michael@0 | 5 | <implementation> |
michael@0 | 6 | <property name="someProp" onget="return 2;" readonly="true"></property> |
michael@0 | 7 | <method name="someMethod"><body> return 3; </body></method> |
michael@0 | 8 | <method name="startTest"> |
michael@0 | 9 | <body> |
michael@0 | 10 | <![CDATA[ |
michael@0 | 11 | // Make sure we only get constructed when we're loaded from a domain |
michael@0 | 12 | // with script enabled. |
michael@0 | 13 | is(this.id, 'allow', "XBL should only be bound when the origin of the binding allows scripts"); |
michael@0 | 14 | |
michael@0 | 15 | var t = this; |
michael@0 | 16 | doFinish = function() { |
michael@0 | 17 | // Take a moment to make sure that other constructors don't run when they shouldn't. |
michael@0 | 18 | if (t.id == 'allow') |
michael@0 | 19 | setTimeout(SpecialPowers.wrap(window.parent).finish, 100); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | onTestEvent = function(target) { |
michael@0 | 23 | ok(true, 'called event handler'); |
michael@0 | 24 | |
michael@0 | 25 | // Try calling event handlers on anonymous content. |
michael@0 | 26 | var e = new MouseEvent('click'); |
michael@0 | 27 | document.getAnonymousNodes(target)[1].dispatchEvent(e); |
michael@0 | 28 | ok(window.calledEventHandlerOnAC, "Should invoke event handler on AC"); |
michael@0 | 29 | |
michael@0 | 30 | // Now, dispatch a key event to test key handlers and move the test along. |
michael@0 | 31 | var k = document.createEvent('KeyboardEvent'); |
michael@0 | 32 | k.initEvent('keyup', true, true); |
michael@0 | 33 | target.dispatchEvent(k); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | // Check the implementation. |
michael@0 | 37 | is(this.someProp, 2, "Properties work"); |
michael@0 | 38 | is(this.someMethod(), 3, "Methods work"); |
michael@0 | 39 | |
michael@0 | 40 | // Kick over to the event handlers. This tests XBL event handlers, |
michael@0 | 41 | // XBL key handlers, and event handlers on anonymous content. |
michael@0 | 42 | this.dispatchEvent(new CustomEvent('testEvent')); |
michael@0 | 43 | ]]> |
michael@0 | 44 | </body> |
michael@0 | 45 | </method> |
michael@0 | 46 | |
michael@0 | 47 | <constructor> |
michael@0 | 48 | <![CDATA[ |
michael@0 | 49 | win = XPCNativeWrapper.unwrap(window); |
michael@0 | 50 | SpecialPowers = win.SpecialPowers; |
michael@0 | 51 | ok = win.ok = SpecialPowers.wrap(window.parent).ok; |
michael@0 | 52 | is = win.is = SpecialPowers.wrap(window.parent).is; |
michael@0 | 53 | info = win.info = SpecialPowers.wrap(window.parent).info; |
michael@0 | 54 | |
michael@0 | 55 | info("Invoked constructor for " + this.id); |
michael@0 | 56 | |
michael@0 | 57 | var t = this; |
michael@0 | 58 | window.addEventListener('load', function loadListener() { |
michael@0 | 59 | window.removeEventListener('load', loadListener); |
michael@0 | 60 | // Wait two refresh-driver ticks to make sure that the constructor runs |
michael@0 | 61 | // for both |allow| and |deny| if it's ever going to. |
michael@0 | 62 | // |
michael@0 | 63 | // See bug 944407 comment 37. |
michael@0 | 64 | info("Invoked load listener for " + t.id); |
michael@0 | 65 | window.requestAnimationFrame(function() { window.requestAnimationFrame(t.startTest.bind(t)); }); |
michael@0 | 66 | }); |
michael@0 | 67 | ]]> |
michael@0 | 68 | </constructor> |
michael@0 | 69 | </implementation> |
michael@0 | 70 | <handlers> |
michael@0 | 71 | <handler event="testEvent" action="onTestEvent(this)" allowuntrusted="true"/> |
michael@0 | 72 | <handler event="keyup" action="ok(true, 'called key handler'); doFinish();" allowuntrusted="true"/> |
michael@0 | 73 | </handlers> |
michael@0 | 74 | <content>Anonymous Content<html:div onclick="window.calledEventHandlerOnAC = true;"></html:div><html:b style="display:none"><children/></html:b></content> |
michael@0 | 75 | </binding> |
michael@0 | 76 | </bindings> |