Bug 918842 - B2G mochitest app doesn't attach the SpecialPowers object to popup windows. r=jmaher
authorMartijn Wargers <mwargers@mozilla.com>
Wed, 25 Sep 2013 19:09:30 +0200
changeset 148885 70ec111942ca8da98490698d1d71dce5d6ecbca0
parent 148884 704346e888a4b6577119978ce8a1cf057b4989b2
child 148886 589d669ef848e15662b36fcb554d94213ce2c435
push id34380
push userryanvm@gmail.com
push dateFri, 27 Sep 2013 01:41:00 +0000
treeherdermozilla-inbound@fdc6054e33e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs918842
milestone27.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 918842 - B2G mochitest app doesn't attach the SpecialPowers object to popup windows. r=jmaher
testing/mochitest/b2g.json
testing/mochitest/b2g_start_script.js
--- a/testing/mochitest/b2g.json
+++ b/testing/mochitest/b2g.json
@@ -184,17 +184,16 @@
     "content/html/content/test/test_fullscreen-api.html":"time out, some kind of focus issue",
 
     "content/html/content/test/test_iframe_sandbox_inheritance.html":"Crash, bug 904659",
     "content/html/content/test/test_iframe_sandbox_navigation2.html":"Crash, bug 904659",
     "content/html/content/test/test_iframe_sandbox_navigation.html":"Crash, bug 904659",
 
     "content/html/content/test/test_iframe_sandbox_plugins.html":"plugins not supported",
     "content/html/content/test/test_object_plugin_nav.html":"plugins not supported",
-    "content/html/document/test/test_bug199692.html":"needs popup to be sized to 600*600",
     "content/html/document/test/test_bug741266.html":"needs control of popup window size",
     "docshell/test/navigation/test_popup-navigates-children.html":"Needs multiple window.open support, also uses docshelltreenode",
     "docshell/test/test_bug590573.html":"queryinterfaces into webnavigation, might suffer from something similar as bug 823022",
     "dom/devicestorage/ipc/test_ipc.html":"nested ipc not working",
 
     "dom/indexedDB/ipc/test_ipc.html":"nested ipc not working",
     "dom/indexedDB/test/test_lowDiskSpace.html":"this needs probably modification for notifyObserversInParentProcess to be similar as pushPermissions",
 
@@ -203,17 +202,16 @@
     "content/base/test/csp/test_CSP_evalscript.html":"observer not working",
     "content/base/test/csp/test_CSP_evalscript_getCRMFRequest.html":"observer not working",
     "content/base/test/csp/test_CSP_frameancestors.html":"observer not working",
     "content/base/test/csp/test_CSP.html":"observer not working",
     "content/base/test/csp/test_bug836922_npolicies.html":"observer not working",
     "content/base/test/csp/test_CSP_bug916446.html":"observer not working",
 
     "content/base/test/test_CrossSiteXHR_origin.html":"https not working, bug 907770",
-    "content/base/test/test_bug326337.html":"popup windows don't have specialpowers installed, could be solved with sendmessage/receivemessage",
     "content/base/test/test_plugin_freezing.html":"",
     "content/base/test/test_bug466409.html":"",
     "content/base/test/test_bug482935.html":"",
     "content/base/test/test_bug498433.html":"",
     "content/base/test/test_bug650386_redirect_301.html":"",
     "content/base/test/test_bug650386_redirect_302.html":"",
     "content/base/test/test_bug650386_redirect_303.html":"",
     "content/base/test/test_bug650386_redirect_307.html":"",
--- a/testing/mochitest/b2g_start_script.js
+++ b/testing/mochitest/b2g_start_script.js
@@ -9,28 +9,46 @@ const CHILD_SCRIPT = "chrome://specialpo
 const CHILD_SCRIPT_API = "chrome://specialpowers/content/specialpowersAPI.js";
 const CHILD_LOGGER_SCRIPT = "chrome://specialpowers/content/MozillaLogger.js";
 
 let homescreen = document.getElementById('systemapp');
 let container = homescreen.contentWindow.document.getElementById('test-container');
 
 function openWindow(aEvent) {
   var popupIframe = aEvent.detail.frameElement;
-  popupIframe.setAttribute('style', 'position: absolute; left: 0; top: 300px; background: white; ');
+  popupIframe.setAttribute('style', 'position: absolute; left: 0; top: 0px; background: white;');
+
+  // This is to size the iframe to what is requested in the window.open call,
+  // e.g. window.open("", "", "width=600,height=600");
+  if (aEvent.detail.features.indexOf('width') != -1) {
+    let width = aEvent.detail.features.substr(aEvent.detail.features.indexOf('width')+6);
+    width = width.substr(0,width.indexOf(',') == -1 ? width.length : width.indexOf(','));
+    popupIframe.style.width = width + 'px';
+  }
+  if (aEvent.detail.features.indexOf('height') != -1) {
+    let height = aEvent.detail.features.substr(aEvent.detail.features.indexOf('height')+7);
+    height = height.substr(0, height.indexOf(',') == -1 ? height.length : height.indexOf(','));
+    popupIframe.style.height = height + 'px';
+  }
 
   popupIframe.addEventListener('mozbrowserclose', function(e) {
     container.parentNode.removeChild(popupIframe);
     container.focus();
   });
 
   // yes, the popup can call window.open too!
   popupIframe.addEventListener('mozbrowseropenwindow', openWindow);
 
   popupIframe.addEventListener('mozbrowserloadstart', function(e) {
     popupIframe.focus();
+    let mm = popupIframe.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
+    mm.loadFrameScript(CHILD_LOGGER_SCRIPT, true);
+    mm.loadFrameScript(CHILD_SCRIPT_API, true);
+    mm.loadFrameScript(CHILD_SCRIPT, true);
+    mm.loadFrameScript('data:,attachSpecialPowersToWindow%28content%29%3B', true);
   });
 
   container.parentNode.appendChild(popupIframe);
 }
 container.addEventListener('mozbrowseropenwindow', openWindow);
 
 if (outOfProcess) {
   let specialpowers = {};