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>
Fri, 22 Feb 2013 07:56:03 -0800
changeset 122657 e177d717382fbfd2afd9f1c28f2286bbcf178798
parent 122656 fe3729c8396d5b3e3f28093bbe4b064ff2faec01
child 122658 b332047abd6c27d470839c450540373d2f753dd5
push id24356
push usergszorc@mozilla.com
push dateSun, 24 Feb 2013 01:00:12 +0000
treeherdermozilla-central@195e706140d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs843231
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 843231 - Alter the XBL scope test to make it compatible with reading the dom.xbl_scopes only once per global. r=bz
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>