<commit_before>/**
 * InitIframe.js
 *
 * Released under LGPL License.
 * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

define(
  'tinymce.core.init.InitIframe',
  [
    'ephox.sugar.api.node.Element',
    'ephox.sugar.api.properties.Attr',
    'ephox.sugar.api.properties.Css',
    'global!document',
    'global!window',
    'tinymce.core.Env',
    'tinymce.core.api.Settings',
    'tinymce.core.dom.DOMUtils',
    'tinymce.core.init.InitContentBody',
    'tinymce.core.util.Uuid'
  ],
  function (Element, Attr, Css, document, window, Env, Settings, DOMUtils, InitContentBody, Uuid) {
    var DOM = DOMUtils.DOM;

    var relaxDomain = function (editor, ifr) {
      // Domain relaxing is required since the user has messed around with document.domain
      // This only applies to IE 11 other browsers including Edge seems to handle document.domain
      if (document.domain !== window.location.hostname && Env.ie && Env.ie < 12) {
        var bodyUuid = Uuid.uuid('mce');

        editor[bodyUuid] = function () {
          InitContentBody.initContentBody(editor);
        };

        /*eslint no-script-url:0 */
        var domainRelaxUrl = 'javascript:(function(){' +
          'document.open();document.domain="' + document.domain + '";' +
          'var ed = window.parent.tinymce.get("' + editor.id + '");document.write(ed.iframeHTML);' +
          'document.close();ed.' + bodyUuid + '(true);})()';

        DOM.setAttrib(ifr, 'src', domainRelaxUrl);
        return true;
      }

      return false;
    };

    var normalizeHeight = function (height) {
      var normalizedHeight = typeof height === 'number' ? height + 'px' : height;
      return normalizedHeight ? normalizedHeight : '';
    };

    var createIframeElement = function (id, title, height, customAttrs) {
      var iframe = Element.fromTag('iframe');

      Attr.setAll(iframe, customAttrs);

      Attr.setAll(iframe, {
        id: id + '_ifr',
        frameBorder: '0',
        allowTransparency: 'true',
        title: title
      });

      Css.setAll(iframe, {
        width: '100%',
        height: normalizeHeight(height),
        display: 'block' // Important for Gecko to render the iframe correctly
      });

      return iframe;<commit_msg>Workaround WebKit regression in which findFrameNamed: no longer works to find the TinyMCE editor frame by it's ID, because the frame's name is only considered to be set by the name attribute. See: https://bugs.webkit.org/show_bug.cgi?id=187937<commit_after>/**
 * InitIframe.js
 *
 * Released under LGPL License.
 * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

define(
  'tinymce.core.init.InitIframe',
  [
    'ephox.sugar.api.node.Element',
    'ephox.sugar.api.properties.Attr',
    'ephox.sugar.api.properties.Css',
    'global!document',
    'global!window',
    'tinymce.core.Env',
    'tinymce.core.api.Settings',
    'tinymce.core.dom.DOMUtils',
    'tinymce.core.init.InitContentBody',
    'tinymce.core.util.Uuid'
  ],
  function (Element, Attr, Css, document, window, Env, Settings, DOMUtils, InitContentBody, Uuid) {
    var DOM = DOMUtils.DOM;

    var relaxDomain = function (editor, ifr) {
      // Domain relaxing is required since the user has messed around with document.domain
      // This only applies to IE 11 other browsers including Edge seems to handle document.domain
      if (document.domain !== window.location.hostname && Env.ie && Env.ie < 12) {
        var bodyUuid = Uuid.uuid('mce');

        editor[bodyUuid] = function () {
          InitContentBody.initContentBody(editor);
        };

        /*eslint no-script-url:0 */
        var domainRelaxUrl = 'javascript:(function(){' +
          'document.open();document.domain="' + document.domain + '";' +
          'var ed = window.parent.tinymce.get("' + editor.id + '");document.write(ed.iframeHTML);' +
          'document.close();ed.' + bodyUuid + '(true);})()';

        DOM.setAttrib(ifr, 'src', domainRelaxUrl);
        return true;
      }

      return false;
    };

    var normalizeHeight = function (height) {
      var normalizedHeight = typeof height === 'number' ? height + 'px' : height;
      return normalizedHeight ? normalizedHeight : '';
    };

    var createIframeElement = function (id, title, height, customAttrs) {
      var iframe = Element.fromTag('iframe');

      Attr.setAll(iframe, customAttrs);

      Attr.setAll(iframe, {
        id: id + '_ifr',
        name: id + '_ifr',
        frameBorder: '0',
        allowTransparency: 'true',
        title: title
      });

      Css.setAll(iframe, {
        width: '100%',
        height: normalizeHeight(height),
        display: 'block' // Important for Gecko to render the iframe correctly
      });

      return iframe;
{'fraction_non_alphanumeric': 0.1394221054758537, 'fraction_numerical': 0.00808244089715094, 'mean_word_length': 2.7585421412300684, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '809255', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1524, 'n_words': 361}