add content policy tests for stand-alone msg windw, r=standard8, 600958
authorDavid Bienvenu <bienvenu@nventure.com>
Mon, 11 Oct 2010 11:57:04 -0700
changeset 6541 ac22bdb43e9945c37a9fb2fa7b4816675302884d
parent 6540 c01b6b5f2b8e9c38e4c064f5d1b41731d3c51b27
child 6542 2f18a77d35c4cbd823e92f2ce0e63c8c67b68fb1
push idunknown
push userunknown
push dateunknown
reviewersstandard8, 600958
bugs600958
add content policy tests for stand-alone msg windw, r=standard8, 600958
mail/test/mozmill/content-policy/test-general-content-policy.js
--- a/mail/test/mozmill/content-policy/test-general-content-policy.js
+++ b/mail/test/mozmill/content-policy/test-general-content-policy.js
@@ -49,17 +49,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 var MODULE_NAME = 'test-general-content-policy';
 
 var RELATIVE_ROOT = '../shared-modules';
-var MODULE_REQUIRES = ['folder-display-helpers', 'compose-helpers'];
+var MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers', 'compose-helpers'];
 var jumlib = {};
 Components.utils.import("resource://mozmill/modules/jum.js", jumlib);
 var elib = {};
 Components.utils.import('resource://mozmill/modules/elementslib.js', elib);
 
 var folder = null;
 var composeHelper = null;
 var gMsgNo = 0;
@@ -123,16 +123,18 @@ const msgBodyStart = '<!DOCTYPE HTML PUB
 '</head>\n' +
 '<body bgcolor="#ffffff" text="#000000">\n';
 
 const msgBodyEnd = '</body>\n</html>\n';
 
 var setupModule = function (module) {
   let fdh = collector.getModule('folder-display-helpers');
   fdh.installInto(module);
+  let wh = collector.getModule('window-helpers');
+  wh.installInto(module);
   composeHelper = collector.getModule('compose-helpers');
   composeHelper.installInto(module);
 
   folder = create_folder("generalContentPolicy");
 };
 
 function addToFolder(aSubject, aBody, aFolder) {
 
@@ -207,16 +209,35 @@ function checkComposeWindow(test, replyT
           .contentDocument.getElementById("testelement")) != loadAllowed)
     throw new Error(test.type + " has not been " +
                     (loadAllowed ? "allowed" : "blocked") +
                     " in reply window as expected.");
 
   composeHelper.close_compose_window(replyWindow);
 }
 
+/**
+ * Check remote content in stand-alone message window, and reload
+ */
+ function checkStandaloneMessageWindow(test, loadAllowed) {
+  plan_for_new_window("mail:messageWindow");
+  // Open it
+  set_open_message_behavior("NEW_WINDOW");
+  open_selected_message();
+  let msgc = wait_for_new_window("mail:messageWindow");
+  wait_for_message_display_completion(msgc, true);
+  if (test.checkForAllowed(
+          msgc.window.content.document.getElementById("testelement")) != loadAllowed)
+    throw new Error(test.type + " has not been blocked in message content as expected.");
+
+  // Clean up, close the window
+  close_message_window(msgc);
+}
+
+
 function allowRemoteContentAndCheck(test) {
   addMsgToFolderAndCheckContent(folder, test);
 
   plan_for_message_display(mc);
 
   // Click on the allow remote content button
   mc.click(new elib.ID(mc.window.document, "remoteContentBarButton"));
 
@@ -261,22 +282,28 @@ function test_generalContentPolicy() {
 
     if (TESTS[i].checkDenied) {
       // Check denied in reply window
       checkComposeWindow(TESTS[i], true, false);
 
       // Check denied in forward window
       checkComposeWindow(TESTS[i], false, false);
 
+      // Check denied in standalone message window
+      checkStandaloneMessageWindow(TESTS[i], false);
+
       // Now allow the remote content and check result
       allowRemoteContentAndCheck(TESTS[i]);
     }
 
     // Check allowed in reply window
     checkComposeWindow(TESTS[i], true, true);
 
     // Check allowed in forward window
     checkComposeWindow(TESTS[i], false, true);
 
+      // Check allowed in standalone message window
+      checkStandaloneMessageWindow(TESTS[i], true);
+
     // Check allowed in content tab
     checkContentTab(TESTS[i]);
   }
 }