/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Checks various remote content policy workings, including:
*
* - Images
* - Video
*
* In:
*
* - Messages
* - Reply email compose window
* - Forward email compose window
* - Content tab
* - Feed message
*/
"use strict";
var utils = ChromeUtils.import("resource://testing-common/mozmill/utils.jsm");
var {
close_compose_window,
open_compose_new_mail,
open_compose_with_forward,
open_compose_with_reply,
} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
var { open_content_tab_with_url } = ChromeUtils.import(
"resource://testing-common/mozmill/ContentTabHelpers.jsm"
);
var {
assert_nothing_selected,
assert_selected_and_displayed,
be_in_folder,
close_message_window,
create_folder,
get_about_message,
mc,
open_message_from_file,
open_selected_message,
plan_for_message_display,
select_click_row,
set_open_message_behavior,
wait_for_message_display_completion,
} = ChromeUtils.import(
"resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
);
var { input_value } = ChromeUtils.import(
"resource://testing-common/mozmill/KeyboardHelpers.jsm"
);
var {
get_notification_button,
wait_for_notification_to_show,
wait_for_notification_to_stop,
} = ChromeUtils.import(
"resource://testing-common/mozmill/NotificationBoxHelpers.jsm"
);
var {
async_plan_for_new_window,
click_menus_in_sequence,
plan_for_modal_dialog,
wait_for_modal_dialog,
wait_for_new_window,
wait_for_window_close,
} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
var { MailServices } = ChromeUtils.import(
"resource:///modules/MailServices.jsm"
);
var folder = null;
var gMsgNo = -1; // msg index in folder
var url =
"http://mochi.test:8888/browser/comm/mail/test/browser/content-policy/html/";
/**
* The TESTS array is constructed from objects containing the following:
*
* type: The type of the test being run.
* body: The html to be inserted into the body of the message under
* test. Note: the element under test for content
* allowed/disallowed should have id 'testelement'.
* webPage: The web page to load during the content tab part of the
* test.
* checkForAllowed: A function that is passed the element with id 'testelement'
* to check for remote content being allowed/disallowed.
* This function should return true if remote content was
* allowed, false otherwise.
*/
var TESTS = [
{
type: "Iframe-Image",
description: "iframe img served over http should be blocked",
shouldBeBlocked: true,
// Blocked from showing by other means. Network request can happen.
neverAllowed: true,
body: `\n`,
checkForAllowed: async element => {
await new Promise(window.requestAnimationFrame);
return element.contentDocument.readyState != "uninitialized";
},
},
{
type: "Iframe-datauri-Image",
description: "iframe datauri img served over http should be blocked",
shouldBeBlocked: true,
// Blocked by other means. MsgContentPolicy accepts the iframe load since
// data: is not a mailnews url. No blocked content notification will show.
neverAllowed: true,
body: `