Bug 1151497 (noscript in feed tab) mozmill test. r=alta88
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Mon, 15 Jun 2015 21:40:21 +0300
changeset 20324 c2fb477b2e171aace353d3b9893ee08a7d432826
parent 20323 e769c32b3fb7b8a65565629d77600fc2a8ed9c60
child 20325 4167ca8ce372e13e75edd4051f84c1574a7ba953
push id1468
push usermbanner@mozilla.com
push dateMon, 29 Jun 2015 20:59:26 +0000
treeherdercomm-aurora@a41650128726 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersalta88
bugs1151497
Bug 1151497 (noscript in feed tab) mozmill test. r=alta88
mail/test/mozmill/content-policy/test-js-content-policy.js
--- a/mail/test/mozmill/content-policy/test-js-content-policy.js
+++ b/mail/test/mozmill/content-policy/test-js-content-policy.js
@@ -17,25 +17,29 @@ var RELATIVE_ROOT = '../shared-modules';
 var MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers'];
 
 var folder = null;
 
 // RELATIVE_ROOT messes with the collector, so we have to bring the path back
 // so we get the right path for the resources.
 var url = collector.addHttpResource('../content-policy/html', 'content');
 
-var setupModule = function (module) {
-  let fdh = collector.getModule('folder-display-helpers');
-  fdh.installInto(module);
-  let wh = collector.getModule('window-helpers');
-  wh.installInto(module);
+function setupModule(module) {
+  for (let lib of MODULE_REQUIRES) {
+    collector.getModule(lib).installInto(module);
+  }
 
   folder = create_folder("jsContentPolicy");
+  Services.prefs.setBoolPref("javascript.enabled", true);
 };
 
+function teardownModule(module) {
+  Services.prefs.clearUserPref("javascript.enabled");
+}
+
 function addToFolder(aSubject, aBody, aFolder) {
 
   let msgId = Components.classes["@mozilla.org/uuid-generator;1"]
                           .getService(Components.interfaces.nsIUUIDGenerator)
                           .generateUUID() +"@mozillamessaging.invalid";
 
   let source = "From - Sat Nov  1 12:39:54 2008\n" +
                "X-Mozilla-Status: 0001\n" +
@@ -167,16 +171,62 @@ function checkJsInFeedContent() {
     throw new Error("noscript display should be 'none'; display=" + display);
 
   ++gMsgNo;
 
   Services.prefs.clearUserPref("rss.show.summary");
 }
 
 /**
+ * Check JavaScript for a feed message viewed in a tab, when the
+ * "View as Web Page" pref is set.
+ */
+function checkJsInFeedTab() {
+  let msgDbHdr = addToFolder("JS test message " + gMsgNo + " (feed!)",
+                             jsMsgBody, folder);
+  msgDbHdr.OrFlags(Ci.nsMsgMessageFlags.FeedMsg);
+
+  // Set to "View as Web Page" so we get the Content-Base page shown.
+  Services.prefs.setIntPref("rss.show.summary", 0);
+
+  // Select the newly created message.
+  let msgHdr = select_click_row(gMsgNo);
+  assert_equals(msgDbHdr, msgHdr,
+                "Selected Message Header is not the same as generated header");
+
+  wait_for_message_display_completion();
+
+  let feedUrl = url + "remote-noscript.html";
+
+  open_selected_message_in_new_tab();
+
+  // The above just ensures local "inline" content have loaded. We need to wait
+  // for the remote content to load too before we check anything.
+  mc.waitFor(() => mc.window.content.wrappedJSObject.location.href == feedUrl &&
+                   mc.window.content.wrappedJSObject.document &&
+                   mc.window.content.wrappedJSObject.document.querySelector("body") != null,
+             "Timeout waiting for remote feed doc to load; url=" +
+              mc.window.content.wrappedJSObject.location);
+
+  if (!mc.window.content.wrappedJSObject.jsIsTurnedOn)
+    throw new Error("JS is turned off for remote feed content - it should be on.");
+
+  let noscript = mc.window.content.wrappedJSObject.document
+                   .getElementsByTagName("noscript")[0];
+  let display = mc.window.getComputedStyle(noscript).getPropertyValue("display");
+  if (display != "none")
+    throw new Error("noscript display should be 'none'; display=" + display);
+
+  ++gMsgNo;
+
+  Services.prefs.clearUserPref("rss.show.summary");
+  close_tab();
+}
+
+/**
  * Check JavaScript when loading remote content in the message pane.
  */
 function checkJsInRemoteContent() {
   // Deselect everything so we can load our content
   select_none();
 
   let mc = mozmill.getMail3PaneController();
   // load something non-message-like in the message pane
@@ -205,10 +255,11 @@ function test_jsContentPolicy() {
   checkJsInMail();
   checkJsInNonMessageContent();
 
   checkJsInMail();
   checkJsInNonMessageContent();
 
   checkJsInFeedContent();
   checkJsInRemoteContent();
+  checkJsInFeedTab();
 
 }