Example #1
0
UnitTest.asynctest('browser.tinymce.core.api.dom.RangeUtilsTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const DOM = DOMUtils.DOM;
  const viewBlock = ViewBlock();

  const createRange = function (sc, so, ec, eo) {
    const rng = DOM.createRng();
    rng.setStart(sc, so);
    rng.setEnd(ec, eo);
    return rng;
  };

  const assertRange = function (expected, actual) {
    Assertions.assertEq('startContainers should be equal', true, expected.startContainer === actual.startContainer);
    Assertions.assertEq('startOffset should be equal', true, expected.startOffset === actual.startOffset);
    Assertions.assertEq('endContainer should be equal', true, expected.endContainer === actual.endContainer);
    Assertions.assertEq('endOffset should be equal', true, expected.endOffset === actual.endOffset);
  };

  const sTestDontNormalizeAtAnchors = Logger.t('Don\'t normalize at anchors', Step.sync(function () {
    viewBlock.update('a<a href="#">b</a>c');

    const rng1 = createRange(viewBlock.get().firstChild, 1, viewBlock.get().firstChild, 1);
    const rng1Clone = rng1.cloneRange();
    Assertions.assertEq('label', false, RangeUtils(DOM).normalize(rng1));
    assertRange(rng1Clone, rng1);

    const rng2 = createRange(viewBlock.get().lastChild, 0, viewBlock.get().lastChild, 0);
    const rng2Clone = rng2.cloneRange();
    Assertions.assertEq('label', false, RangeUtils(DOM).normalize(rng2));
    assertRange(rng2Clone, rng2);
  }));

  const sTestNormalize = GeneralSteps.sequence([
    sTestDontNormalizeAtAnchors
  ]);

  Pipeline.async({}, [
    sTestNormalize
  ], function () {
    viewBlock.detach();
    success();
  }, failure);
});
Example #2
0
  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const steps = Env.webkit ? [
      Logger.t('paste plain text',
        GeneralSteps.sequence([
          tinyApis.sExecCommand('mceTogglePlainTextPaste'),
          Paste.sPaste(editor, { 'text/html': '<p><strong>test</strong></p>'}),
          tinyApis.sAssertContent('<p>test</p>'),
          tinyApis.sSetContent(''),
          tinyApis.sExecCommand('mceTogglePlainTextPaste'),
          Paste.sPaste(editor, { 'text/html': '<p><strong>test</strong></p>'}),
          tinyApis.sAssertContent('<p><strong>test</strong></p>')
        ])
      )
    ] : [];

    Pipeline.async({}, steps, onSuccess, onFailure);
  }, {
  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);

    Pipeline.async({}, [
      Logger.t('Should insert a before b', GeneralSteps.sequence([
        tinyApis.sSetContent('<p>b</p>'),
        tinyApis.sSetSelection([0, 0], 0, [0, 0], 0),
        sSetContent(editor, 'a', {}),
        tinyApis.sAssertContent('<p>ab</p>')
      ])),
      Logger.t('Should fill the body with x h1 instead of a before b in a paragraph', GeneralSteps.sequence([
        tinyApis.sSetContent('<p>b</p>'),
        tinyApis.sSetSelection([0, 0], 0, [0, 0], 0),
        sSetContentOverride(editor, 'a', '<h1>x</h1>', {}),
        tinyApis.sAssertContent('<h1>x</h1>')
      ]))
    ], onSuccess, onFailure);
  }, {
Example #4
0
  const sFormatBlockTests = function (editor, tinyApis) {
    const sFormatBlockTest = function (name) {
      const sFormatBlock: any = wrap(Actions.formatBlock, editor);

      return GeneralSteps.sequence([
        tinyApis.sSetContent('<p>a</p>'),
        tinyApis.sSetCursor([0], 0),
        sFormatBlock(name),
        tinyApis.sAssertContent('<' + name + '>a</' + name + '>', 'Should be a ' + name + ' block')
      ]);
    };

    return GeneralSteps.sequence([
      sFormatBlockTest('h1'),
      sFormatBlockTest('h2'),
      sFormatBlockTest('pre')
    ]);
  };
Example #5
0
  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const tinyUi = TinyUi(editor);

    Pipeline.async({}, [
      Logger.t('should not get anchor info if not selected node', GeneralSteps.sequence([
        tinyApis.sSetContent('<p><a href="http://tinymce.com">tiny</a></p>'),
        tinyApis.sSetSelection([0], 1, [0], 1),
        tinyApis.sExecCommand('mcelink'),
        Chain.asStep({}, [
          tinyUi.cWaitForPopup('wait for link popup', 'div[role="dialog"][aria-label="Insert link"]'),
          UiFinder.cFindIn('label:contains("Url") + div > input'),
          UiControls.cGetValue,
          Assertions.cAssertEq('assert value is nothing', '')
        ])
      ]))
    ], onSuccess, onFailure);
  }, {
 const sManipulateImage = function (message, url) {
   return Logger.t(message, GeneralSteps.sequence([
     ImageUtils.sLoadImage(editor, url),
     tinyApis.sSelect('img', []),
     imgOps.sExecToolbar('Flip horizontally'),
     imgOps.sExecToolbar('Rotate clockwise'),
     imgOps.sExecDialog('Invert'),
     imgOps.sExecDialog('Crop'),
     imgOps.sExecDialog('Resize'),
     imgOps.sExecDialog('Flip vertically'),
     imgOps.sExecDialog('Rotate clockwise'),
     imgOps.sExecDialog('Brightness'),
     imgOps.sExecDialog('Sharpen'),
     imgOps.sExecDialog('Contrast'),
     imgOps.sExecDialog('Color levels'),
     imgOps.sExecDialog('Gamma')
   ]));
 };
Example #7
0
  const sCreateLinkTests = function (editor, tinyApis) {
    const sCreateLinkTest = function (inputHtml, url, sPath, sOffset, fPath, fOffset, expectedHtml) {
      const sCreateLink: any = wrap(Actions.createLink, editor);

      return GeneralSteps.sequence([
        tinyApis.sSetContent(inputHtml),
        tinyApis.sSetSelection(sPath, sOffset, fPath, fOffset),
        sCreateLink(url),
        tinyApis.sAssertContent(expectedHtml, 'Should have a link')
      ]);
    };

    return GeneralSteps.sequence([
      sCreateLinkTest('<p>a</p>', '#1', [0, 0], 0, [0, 0], 1, '<p><a href="#1">a</a></p>'),
      sCreateLinkTest('<p><a href="#1">a</a></p>', '#2', [0, 0], 0, [0, 0], 1, '<p><a href="#2">a</a></p>'),
      sCreateLinkTest('<p><a href="#1"><em>a</em></a></p>', '#2', [0, 0, 0], 0, [0, 0, 0], 1, '<p><a href="#2"><em>a</em></a></p>')
    ]);
  };
Example #8
0
  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyUi = TinyUi(editor);

    Pipeline.async({}, [
      Logger.t('image proportion constrains should work directly', GeneralSteps.sequence([
        tinyUi.sClickOnToolbar('click image button', 'div[aria-label="Insert/edit image"] button'),
        Chain.asStep({}, [
          Chain.fromParent(tinyUi.cWaitForPopup('Wait for dialog', 'div[role="dialog"]'),
            [
              Chain.fromChains([
                UiFinder.cFindIn('i.mce-i-browse'),
                Mouse.cClick
              ]),
              Chain.fromChains([
                Chain.control(
                  Chain.fromChains([
                    UiFinder.cFindIn('input[aria-label="Width"]'),
                    UiControls.cGetValue,
                    Assertions.cAssertEq('should be 1', '1')
                  ]),
                  Guard.tryUntil('did not find input with value 1', 10, 3000)
                )
              ]),
              Chain.fromChains([
                UiFinder.cFindIn('input[aria-label="Height"]'),
                UiControls.cSetValue('5'),
                cFakeEvent('change')
              ]),
              Chain.fromChains([
                UiFinder.cFindIn('input[aria-label="Width"]'),
                UiControls.cGetValue,
                Assertions.cAssertEq('should have changed to 5', '5')
              ]),
              Chain.fromChains([
                UiFinder.cFindIn('div.mce-primary button'),
                Mouse.cClick
              ])
            ]
          )
        ])
      ]))

    ], onSuccess, onFailure);
  }, {
  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const tinyUi = TinyUi(editor);

    Pipeline.async({}, [
      Logger.t('test default count of toolbar buttons', GeneralSteps.sequence([
        tinyApis.sFocus,
        tinyApis.sSetContent(tableHtml),
        TableTestUtils.sOpenToolbarOn(editor, 'table td', [0]),
        Chain.asStep({}, [
          tinyUi.cWaitForUi('no context found', 'div.tox-pop div.tox-toolbar'),
          Chain.mapper(function (x) {
            return SelectorFilter.descendants(x, 'button').length;
          }),
          Assertions.cAssertEq('has correct count', 8)
        ])
      ]))
    ], onSuccess, onFailure);
  }, {
Example #10
0
  const sUnlinkTests = function (editor, tinyApis) {
    const sUnlinkTest = function (inputHtml, sPath, sOffset, fPath, fOffset, expectedHtml) {
      const sUnlink = wrap(Actions.unlink, editor);

      return GeneralSteps.sequence([
        tinyApis.sSetContent(inputHtml),
        tinyApis.sSetSelection(sPath, sOffset, fPath, fOffset),
        sUnlink(),
        tinyApis.sAssertContent(expectedHtml, 'Should not have a link')
      ]);
    };

    return GeneralSteps.sequence([
      sUnlinkTest('<p>a</p>', [0, 0], 0, [0, 0], 1, '<p>a</p>'),
      sUnlinkTest('<p><a href="#">a</a></p>', [0, 0, 0], 0, [0, 0, 0], 1, '<p>a</p>'),
      sUnlinkTest('<p><a href="#"><em>a</em></a></p>', [0, 0, 0], 0, [0, 0, 0], 1, '<p><em>a</em></p>'),
      sUnlinkTest('<p><a href="#">a</a>b</p>', [0, 0, 0], 0, [0, 1], 1, '<p>ab</p>')
    ]);
  };
 const sTestEnterAtStartOfAnchorZwspWithAdjacentContent = function (tinyApis, tinyActions) {
   return Logger.t(
     'sTestEnterAtStartOfAnchorZwspWithAdjacentContent',
     GeneralSteps.sequence([
       sSetup(tinyApis, '<p>a<a href="#">' + Zwsp.ZWSP + 'b</a>c</p>', [0, 1, 0], 1),
       sEnterKey(tinyActions),
       tinyApis.sAssertContentStructure(
         ApproxStructure.build(function (s, str, arr) {
           return s.element('body', {
             children: [
               s.element('p', {
                 children: [
                   s.text(str.is('a')),
                   s.element('a', {
                     attrs: {
                       'data-mce-href': str.is('#'),
                       'href': str.is('#')
                     }
                   })
                 ]
               }),
               s.element('p', {
                 children: [
                   s.element('a', {
                     attrs: {
                       'data-mce-href': str.is('#'),
                       'href': str.is('#')
                     },
                     children: [
                       s.text(str.is(Zwsp.ZWSP + 'b'))
                     ]
                   }),
                   s.text(str.is('c'))
                 ]
               })
             ]
           });
         })
       ),
       tinyApis.sAssertSelection([1, 0, 0], 1, [1, 0, 0], 1)
     ])
   );
 };
Example #12
0
  const sInsertBlobTests = function (editor, tinyApis) {
    const sInsertBlobTest = function (inputHtml, path, offset, blob, base64, expectedHtml) {
      const sInsertBlob: any = wrap(Actions.insertBlob, editor);

      return GeneralSteps.sequence([
        tinyApis.sSetContent(inputHtml),
        tinyApis.sSetCursor(path, offset),
        sInsertBlob(blob, base64),
        tinyApis.sAssertContent(expectedHtml, 'Should have a image')
      ]);
    };

    const base64 = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
    const blob = base64ToBlob(base64, 'image/gif');

    return GeneralSteps.sequence([
      sInsertBlobTest('<p>a</p>', [0, 0], 0, base64, blob, '<p><img src="data:image/gif;base64,' + base64 + '" />a</p>')
    ]);
  };
 const sTestDialogLabelled = (params) =>
   Logger.t(
     `Dialog should have "aria-labelledby" for config "${JSON.stringify(params)}"`,
     GeneralSteps.sequence([
       Step.sync(() => {
           const dialogSpec: Types.Dialog.DialogApi<{}> = {
             title: 'Silver Test Inline (Toolbar) Dialog',
             body: {
               type: 'panel',
               items: []
             },
             buttons: [],
             initialData: {}
           };
           windowManager.open(dialogSpec, params, Fun.noop );
       }),
       sAssertDialogLabelledBy,
     ])
   );
Example #14
0
const sAssertSizeRecalcConstrainedReopen = function (ui) {
  return GeneralSteps.sequence([
    sOpenDialog(ui),
    sPasteSourceValue(ui, 'http://test.se'),
    sAssertWidthValue(ui, '300'),
    sAssertHeightValue(ui, '150'),
    sChangeWidthValue(ui, '350'),
    sAssertWidthValue(ui, '350'),
    sAssertHeightValue(ui, '175'),
    sChangeHeightValue(ui, '100'),
    sAssertHeightValue(ui, '100'),
    sAssertWidthValue(ui, '200'),
    sSubmitAndReopen(ui),
    sAssertHeightValue(ui, '100'),
    sAssertWidthValue(ui, '200'),
    sChangeWidthValue(ui, '350'),
    sAssertWidthValue(ui, '350'),
    sAssertHeightValue(ui, '175')
  ]);
};
  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);

    Pipeline.async({}, [
      Logger.t('Toggle on/off visualblocks and compute previews', GeneralSteps.sequence([
        tinyApis.sExecCommand('mceVisualBlocks'),
        sWaitForVisualBlocks(editor),
        Step.sync(function () {
          Assertions.assertEq('Visual blocks class should exist', true, Class.has(Element.fromDom(editor.getBody()), 'mce-visualblocks'));
          Assertions.assertEq('Should not have a border property', true, editor.formatter.getCssText('h1').indexOf('border:1px dashed') === -1);
        }),
        tinyApis.sExecCommand('mceVisualBlocks'),
        Step.sync(function () {
          Assertions.assertEq('Visual blocks class should not exist', false, Class.has(Element.fromDom(editor.getBody()), 'mce-visualblocks'));
          Assertions.assertEq('Should not have a border property', true, editor.formatter.getCssText('h1').indexOf('border:1px dashed') === -1);
          Assertions.assertEq('Visual blocks class should still not exist', false, Class.has(Element.fromDom(editor.getBody()), 'mce-visualblocks'));
        })
      ]))
    ], onSuccess, onFailure);
  }, {
Example #16
0
  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const tinyUi = TinyUi(editor);

    Pipeline.async({}, [
      tinyApis.sFocus,
      Logger.t('removing src in dialog should remove figure element', GeneralSteps.sequence([
        tinyApis.sSetContent('<figure class="image"><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="" /><figcaption>x</figcaption></figure>'),
        tinyApis.sSetSelection([], 1, [], 2),
        tinyUi.sClickOnToolbar('click on image button', 'div[aria-label="Insert/edit image"] button'),
        Chain.asStep({}, [
          tinyUi.cWaitForPopup('Wait for dialog', 'div[role="dialog"]'),
          UiFinder.cFindIn('label:contains("Source")'),
          Chain.mapper(function (val) {
            const inputElm = document.getElementById(val.dom().htmlFor).querySelector('input');
            return TinyDom.fromDom(inputElm);
          }),
          UiControls.cSetValue('')
        ]),
        tinyUi.sClickOnUi('click on ok button', 'button:contains("Ok")'),
        tinyApis.sAssertContent('')
      ])),

      Logger.t('clicking caption textbox removes figure and adds image only', GeneralSteps.sequence([
        tinyApis.sSetContent('<figure class="image"><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="" /><figcaption>x</figcaption></figure>'),
        tinyApis.sSetSelection([], 1, [], 2),
        tinyUi.sClickOnToolbar('click on image button', 'div[aria-label="Insert/edit image"] button'),
        Chain.asStep({}, [
          tinyUi.cWaitForPopup('Wait for dialog', 'div[role="dialog"]'),
          UiFinder.cFindIn('label:contains("Caption")'),
          Chain.mapper(function (val) {
            return TinyDom.fromDom(document.getElementById(val.dom().htmlFor));
          }),
          Mouse.cClick
        ]),
        tinyUi.sClickOnUi('click on ok button', 'button:contains("Ok")'),
        tinyApis.sAssertContentPresence({ 'figure.image': 0 })
      ]))

    ], onSuccess, onFailure);
  }, {
Example #17
0
    const testNoProtocolConfirm = (url) => {
      const presence = {};
      presence[`a[href="${url}"]:contains("Something")`] = 1;

      return GeneralSteps.sequence([
        tinyApis.sSetContent('<p>Something</p>'),
        tinyApis.sSetSelection([ 0, 0 ], ''.length, [ 0, 0 ], 'Something'.length),
        TestLinkUi.sOpenLinkDialog,

        FocusTools.sSetActiveValue(doc, url),
        TestLinkUi.sAssertDialogContents({
          href: url,
          text: 'Something',
          title: '',
          target: ''
        }),
        TestLinkUi.sClickSave,
        UiFinder.sNotExists(TinyDom.fromDom(document.body), '[role="dialog"]'),
        TestLinkUi.sAssertContentPresence(tinyApis, presence)
      ]);
    };
  const sAssertGetContentOverrideBeforeGetContent = (label: string, editor: Editor, expectedContents: string, args: any = {}) => {
    const handler = (e) => {
      if (e.selection === true) {
        e.preventDefault();
        e.content = expectedContents;
      }
    };

    return GeneralSteps.sequence([
      Step.sync(function () {
        editor.on('BeforeGetContent', handler);
      }),
      Chain.asStep(editor, [
        cGetContent(args),
        Assertions.cAssertEq('Should be expected contents', expectedContents)
      ]),
      Step.sync(function () {
        editor.off('BeforeGetContent', handler);
      })
    ]);
  };
 const sTestEnterAtEndOfAnchorZwsp = function (tinyApis, tinyActions) {
   return Logger.t(
     'sTestEnterAtEndOfAnchorZwsp',
     GeneralSteps.sequence([
       sSetup(tinyApis, '<p><a href="#">a' + Zwsp.ZWSP + '</a></p>', [0, 0, 0], 2),
       sEnterKey(tinyActions),
       tinyApis.sAssertContentStructure(
         ApproxStructure.build(function (s, str, arr) {
           return s.element('body', {
             children: [
               s.element('p', {
                 children: addGeckoBr(s, str, [
                   s.element('a', {
                     attrs: {
                       'data-mce-href': str.is('#'),
                       'href': str.is('#')
                     },
                     children: [
                       s.text(str.is('a' + Zwsp.ZWSP))
                     ]
                   })
                 ])
               }),
               s.element('p', {
                 children: [
                   s.element('br', {
                     attrs: {
                       'data-mce-bogus': str.is('1')
                     }
                   })
                 ]
               })
             ]
           });
         })
       ),
       tinyApis.sAssertSelection([1], 0, [1], 0)
     ])
   );
 };
Example #20
0
    const testProtocolConfirm = (url, expectedProtocol) => {
      const presence = {};
      presence[`a[href="${expectedProtocol}${url}"]:contains("Something")`] = 1;

      return GeneralSteps.sequence([
        tinyApis.sSetContent('<p>Something</p>'),
        tinyApis.sSetSelection([ 0, 0 ], ''.length, [ 0, 0 ], 'Something'.length),
        TestLinkUi.sOpenLinkDialog,

        FocusTools.sSetActiveValue(doc, url),
        TestLinkUi.sAssertDialogContents({
          href: url,
          text: 'Something',
          title: '',
          target: ''
        }),
        TestLinkUi.sClickSave,
        TestLinkUi.sWaitForUi('Wait for confirm dialog to show', '[role="dialog"].tox-confirm-dialog'),
        TestLinkUi.sClickConfirmYes,
        TestLinkUi.sAssertContentPresence(tinyApis, presence)
      ]);
    };
Example #21
0
 const sInsertTableTests = function (editor, tinyApis) {
   return GeneralSteps.sequence([
     tinyApis.sSetContent('<p><br></p><p>b</p>'),
     tinyApis.sSetCursor([0], 0),
     Toolbar.sClickButton('Insert table'),
     sAssertTableStructure(editor, ApproxStructure.fromHtml([
       '<table style="border-collapse: collapse; width: 100%;" border="1">',
       '<tbody>',
       '<tr>',
       '<td style="width: 50%;"><br></td>',
       '<td style="width: 50%;"><br></td>',
       '</tr>',
       '<tr>',
       '<td style="width: 50%;"><br></td>',
       '<td style="width: 50%;"><br></td>',
       '</tr>',
       '</tbody>',
       '</table>'
     ].join(''))
     )
   ]);
 };
  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const tinyUi = TinyUi(editor);

    Pipeline.async({}, [
      Logger.t('test table grid disabled', GeneralSteps.sequence([
        tinyApis.sFocus,
        tinyUi.sClickOnMenu('click table menu', 'span:contains("Table")'),
        tinyUi.sClickOnUi('click table menu', 'div[role="menu"] span:contains("Table")'),
        Chain.asStep({}, [
          tinyUi.cWaitForPopup('wait for popup', 'div[aria-label="Table properties"][role="dialog"]'),
          Chain.op(function (x) {
            Assertions.assertPresence(
              'assert presence of col and row input',
              {
                'label:contains("Cols")': 1,
                'label:contains("Rows")': 1
              }, x);
          })
        ])
      ]))
    ], onSuccess, onFailure);
  }, {
 const sInsertTableTests = function (tinyApis) {
   return GeneralSteps.sequence([
     tinyApis.sSetContent('<p><br></p><p>b</p>'),
     tinyApis.sSetCursor([0], 0),
     Toolbar.sClickButton('Insert table'),
     tinyApis.sAssertContent([
       '<table style="width: 100%;">',
       '<tbody>',
       '<tr>',
       '<td>&nbsp;</td>',
       '<td>&nbsp;</td>',
       '</tr>',
       '<tr>',
       '<td>&nbsp;</td>',
       '<td>&nbsp;</td>',
       '</tr>',
       '</tbody>',
       '</table>',
       '<p>b</p>'
     ].join('\n')
     )
   ]);
 };
  TinyLoader.setup(function (editor: Editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const tinyUi = TinyUi(editor);

    Pipeline.async({}, [
      Logger.t('change background color on selected table cells', GeneralSteps.sequence([
        tinyApis.sSetContent(
          '<table style="border-collapse: collapse;" border="1"><tbody><tr><td style="background-color: blue;" data-mce-selected="1">a</td><td style="background-color: blue;" data-mce-selected="1">b</td></tr></tbody></table>'
        ),
        tinyApis.sSetSelection([0, 0, 0, 1, 0], 1, [0, 0, 0, 1, 0], 1),
        tinyApis.sExecCommand('mceTableCellProps'),
        Chain.asStep({}, [
          tinyUi.cWaitForPopup('cell prop popup', 'div[aria-label="Cell properties"]'),
          tinyUi.cFillDialogWith({ backgroundColor: 'red'}),
          UiFinder.cFindIn('button:contains("Ok")'),
          Mouse.cClick
        ]),
        tinyApis.sAssertContent(
          '<table style="border-collapse: collapse;" border="1"><tbody><tr><td style="background-color: red;">a</td><td style="background-color: red;">b</td></tr></tbody></table>'
        ),
      ]))
    ], onSuccess, onFailure);
  }, {
Example #25
0
  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const tinyUi = TinyUi(editor);

    Pipeline.async({}, [
      Logger.t('test table grid disabled', GeneralSteps.sequence([
        tinyApis.sFocus,
        tinyUi.sClickOnMenu('click table menu', 'span:contains("Table")'),
        Waiter.sTryUntil('click table menu', tinyUi.sClickOnUi('click table menu', 'div.tox-menu div.tox-collection__item .tox-collection__item-label:contains("Table")'), 10, 1000),
        Chain.asStep({}, [
          tinyUi.cWaitForPopup('wait for popup', 'div.tox-dialog:has(div.tox-dialog__title:contains("Table Properties"))'),
          Chain.op(function (x) {
            Assertions.assertPresence(
              'assert presence of col and row input',
              {
                'label:contains("Cols")': 1,
                'label:contains("Rows")': 1
              }, x);
          })
        ])
      ]))
    ], onSuccess, onFailure);
  }, {
  const sInsertTheCorrectMessage = (label) => {
    return GeneralSteps.sequence([
      sCreateConfirm(label, Fun.noop),
      Step.sync(() => {
        const body = document.querySelector('.tox-dialog__body');
        Assertions.assertStructure('A basic confirm dialog should have these components',
          ApproxStructure.build((s, str, arr) => {
            return s.element('div', {
              classes: [ arr.has('tox-dialog__body')],
              children: [
                s.element('p', {
                  html: str.is(label)
                })
              ]
            });
          }),
          SugarElement.fromDom(body)
        );
      }),
      sTeardown

    ]);
  };
Example #27
0
  TinyLoader.setup((editor: Editor, onSuccess, onFailure) => {
    const tinyApis = TinyApis(editor);

    const sAssertToolbarNotVisible = GeneralSteps.sequence([
      // We can't wait for something to happen, as nothing will change. So instead, just wait some time for when the toolbar would have normally shown
      Step.wait(200),
      UiFinder.sNotExists(Body.body(), '.tox-pop__dialog .tox-toolbar')
    ]);

    Pipeline.async({}, [
      tinyApis.sFocus,
      Log.stepsAsStep('TBA', 'Text selection toolbar is not shown', [
        tinyApis.sSetContent('<p>Some <strong>bold</strong> and <em>italic</em> content.</p><blockquote><p>Some quoted content</p></blockquote>'),
        tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
        sAssertToolbarNotVisible
      ]),
      Log.stepsAsStep('TBA', 'Insert toolbar is not shown', [
        tinyApis.sSetContent('<p>Some <strong>bold</strong> and <em>italic</em> content.</p><p></p>'),
        tinyApis.sSetSelection([1], 0, [1], 0),
        sAssertToolbarNotVisible
      ])
    ], onSuccess, onFailure);
  }, {
  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);

    Pipeline.async({}, [
      tinyApis.sFocus,
      Logger.t('Click on content editable false', GeneralSteps.sequence([
        tinyApis.sSetContent('<p contenteditable="false">a</p>'),
        sClickMiddleOf(editor, [0]),
        tinyApis.sAssertSelection([], 0, [], 1)
      ])),
      Logger.t('Click on content editable false inside content editable true', GeneralSteps.sequence([
        tinyApis.sSetContent('<div contenteditable="true"><p contenteditable="false">a</p></div>'),
        sClickMiddleOf(editor, [0, 0]),
        tinyApis.sAssertSelection([0], 0, [0], 1)
      ])),
      Logger.t('Click on content editable true inside content editable false', GeneralSteps.sequence([
        tinyApis.sSetContent('<div contenteditable="false"><p contenteditable="true">a</p></div>'),
        sClickMiddleOf(editor, [0, 0]),
        tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1)
      ])),
      Logger.t('Click on content editable false inside content editable true and then on content editable true and type', GeneralSteps.sequence([
        tinyApis.sSetContent('<div contenteditable="true"><p contenteditable="false">a</p><p>b</p></div>'),
        sClickMiddleOf(editor, [0, 0]),
        sClickMiddleOf(editor, [0, 1]),
        tinyApis.sAssertSelection([0, 1, 0], 1, [0, 1, 0], 1),
        TypeText.sTypeContentAtSelection(Element.fromDom(editor.getDoc()), 'c'),
        tinyApis.sAssertContent('<div contenteditable="true"><p contenteditable="false">a</p><p>bc</p></div>'),
        tinyApis.sAssertSelection([0, 1, 0], 2, [0, 1, 0], 2)
      ])),
      Logger.t('Click on content editable false then outside on content editable inherit', GeneralSteps.sequence([
        tinyApis.sSetContent('<p contenteditable="false">a</p><p>a</p>'),
        sClickMiddleOf(editor, [0]),
        sClickMiddleOf(editor, [1]),
        tinyApis.sAssertSelection([1, 0], 1, [1, 0], 1)
      ]))
    ], onSuccess, onFailure);
  }, {
  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);
    const steps = Env.ie ? [] : [
      tinyApis.sFocus,
      Logger.t('Chrome adds a nbsp between link and text', GeneralSteps.sequence([
        tinyApis.sSetContent('<p><a href="http://www.domain.com">www.domain.com</a>&nbsp;www.domain.com</p>'),
        tinyApis.sSetCursor([0, 1], 15),
        Step.sync(function () {
          KeyUtils.type(editor, ' ');
        }),
        tinyApis.sAssertContent('<p><a href="http://www.domain.com">www.domain.com</a>&nbsp;<a href="http://www.domain.com">www.domain.com</a>&nbsp;</p>')
      ])),
      Logger.t('FireFox does not seem to add a nbsp between link and text', GeneralSteps.sequence([
        tinyApis.sSetContent('<p><a href="http://www.domain.com">www.domain.com</a> www.domain.com</p>'),
        tinyApis.sSetCursor([0, 1], 15),
        Step.sync(function () {
          KeyUtils.type(editor, ' ');
        }),
        tinyApis.sAssertContent('<p><a href="http://www.domain.com">www.domain.com</a> <a href="http://www.domain.com">www.domain.com</a>&nbsp;</p>')
      ]))
    ];

    Pipeline.async({}, steps, onSuccess, onFailure);
  }, {
Example #30
0
  const sLinkTests = function (tinyApis, tinyActions) {
    const sContentActionTest = function (inputHtml, spath, soffset, fpath, foffset, expectedHtml, sAction) {
      return GeneralSteps.sequence([
        tinyApis.sSetContent(inputHtml),
        tinyApis.sSetSelection(spath, soffset, fpath, foffset),
        tinyActions.sContentKeystroke(Keys.space(), {}),
        sAction,
        tinyApis.sAssertContent(expectedHtml)
      ]);
    };

    const sLinkTest = function (inputHtml, spath, soffset, fpath, foffset, url, expectedHtml) {
      return sContentActionTest(inputHtml, spath, soffset, fpath, foffset, expectedHtml, sInsertLink(url));
    };

    const sUnlinkTest = function (inputHtml, spath, soffset, fpath, foffset, expectedHtml) {
      return sContentActionTest(inputHtml, spath, soffset, fpath, foffset, expectedHtml, sUnlink);
    };

    const sLinkWithConfirmOkTest = function (inputHtml, spath, soffset, fpath, foffset, url, expectedHtml) {
      return sContentActionTest(inputHtml, spath, soffset, fpath, foffset, expectedHtml, sInsertLinkConfirmPrefix(url, 'Ok'));
    };

    const sLinkWithConfirmCancelTest = function (inputHtml, spath, soffset, fpath, foffset, url, expectedHtml) {
      return sContentActionTest(inputHtml, spath, soffset, fpath, foffset, expectedHtml, sInsertLinkConfirmPrefix(url, 'Cancel'));
    };

    return GeneralSteps.sequence([
      sLinkWithConfirmOkTest('<p>a</p>', [0, 0], 0, [0, 0], 1, 'www.site.com', '<p><a href="http://www.site.com">a</a></p>'),
      sLinkWithConfirmCancelTest('<p>a</p>', [0, 0], 0, [0, 0], 1, 'www.site.com', '<p><a href="www.site.com">a</a></p>'),
      sLinkTest('<p>a</p>', [0, 0], 0, [0, 0], 1, '#1', '<p><a href="#1">a</a></p>'),
      sLinkTest('<p><a id="x" href="#1">a</a></p>', [0, 0, 0], 0, [0, 0, 0], 1, '#2', '<p><a id="x" href="#2">a</a></p>'),
      sLinkTest('<p><a href="#3">a</a></p>', [0, 0, 0], 0, [0, 0, 0], 1, '', '<p>a</p>'),
      sUnlinkTest('<p><a id="x" href="#1">a</a></p>', [0, 0, 0], 0, [0, 0, 0], 1, '<p>a</p>')
    ]);
  };