Bug 843231 - Alter the XBL scope test to make it compatible with reading the dom.xbl_scopes only once per global. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Wed, 27 Mar 2013 11:40:43 -0700
changeset 128701 dedc70b52eaa50a7b14828de3da0e1f1ebd0e4f1
parent 128700 add20e9fce39967ebbeb60dc684112e87a7076bf
child 128702 033f2f8ee525c5b135c306b1227c288b0b549db8
push id3562
push userbobbyholley@gmail.com
push dateWed, 27 Mar 2013 18:41:22 +0000
treeherdermozilla-aurora@c5add7fbc027 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs843231, 821850
milestone21.0a2
Bug 843231 - Alter the XBL scope test to make it compatible with reading the dom.xbl_scopes only once per global. r=bz --HG-- rename : content/xbl/test/test_bug821850.xhtml => content/xbl/test/file_bug821850.xhtml
content/xbl/test/Makefile.in
content/xbl/test/file_bug821850.xhtml
content/xbl/test/test_bug821850.html
content/xbl/test/test_bug821850.xhtml
--- a/content/xbl/test/Makefile.in
+++ b/content/xbl/test/Makefile.in
@@ -33,17 +33,18 @@ MOCHITEST_FILES =	\
 		file_bug481558.xbl \
 		test_bug526178.xhtml \
 		test_bug542406.xhtml \
 		test_bug591198.html \
 		file_bug591198_xbl.xml \
 		file_bug591198_inner.html \
 		test_bug639338.xhtml \
 		test_bug790265.xhtml \
-		test_bug821850.xhtml \
+		test_bug821850.html \
+		file_bug821850.xhtml \
 		$(NULL)
 
 MOCHITEST_CHROME_FILES = \
 		test_bug378518.xul \
 		test_bug398135.xul \
 		test_bug398492.xul \
 		test_bug721452.xul \
 		test_bug723676.xul \
rename from content/xbl/test/test_bug821850.xhtml
rename to content/xbl/test/file_bug821850.xhtml
--- a/content/xbl/test/test_bug821850.xhtml
+++ b/content/xbl/test/file_bug821850.xhtml
@@ -1,16 +1,13 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=821850
 -->
 <head>
-  <title>Test for Bug 821850</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <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.
@@ -82,18 +79,20 @@ https://bugzilla.mozilla.org/show_bug.cg
       <handlers>
         <handler event="testevent" action="ok(true, 'called event handler'); finish();"/>
       </handlers>
     </binding>
   </bindings>
   <script type="application/javascript">
   <![CDATA[
 
-  /** Test for XBL scope behavior. **/
-  SimpleTest.waitForExplicitFinish();
+  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");
 
   function go() {
@@ -107,17 +106,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     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 = $('bound');
+    var bound = document.getElementById('bound');
     is(bound.primitiveField, 2, "Can see primitive fields");
     is(typeof bound.objectField, "object", "objectField exists");
     checkThrows(function() bound.objectField.foo);
     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");
 
@@ -186,24 +185,20 @@ https://bugzilla.mozilla.org/show_bug.cg
   }
 
   function checkAllowed(fn, desc) {
     try { fn(); ok(true, desc + ": Didn't throw"); }
     catch (e) { ok(false, desc + ": Threw: " + e); }
   }
 
   function setup() {
-    SpecialPowers.pushPrefEnv({set: [['dom.xbl_scopes', true]] }, continueSetup);
-  }
-
-  function continueSetup() {
     // When the bindings are applied, the constructor will be invoked and the
     // test will continue.
-    $('bound').style.MozBinding = 'url(#testBinding)';
-    $('bound2').style.MozBinding = 'url(#testBinding)';
+    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>
new file mode 100644
--- /dev/null
+++ b/content/xbl/test/test_bug821850.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=821850
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 821850</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+
+  /** Test for XBL scope behavior. **/
+  SimpleTest.waitForExplicitFinish();
+
+  // The XBL scope pref is read when a global is constructed, so we need to set
+  // it before loading the test.
+  function setup() {
+    SpecialPowers.pushPrefEnv({set: [['dom.xbl_scopes', true]] }, continueSetup);
+  }
+
+  // Embed the real test. It will take care of everything else.
+  function continueSetup() {
+    $('ifr').setAttribute('src', 'file_bug821850.xhtml');
+  }
+
+  </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">
+<iframe id="ifr"></iframe>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>