Skip to content

Commit

Permalink
TINY-10639: Update Jenkins to Safari 17 and fix test failures (#9473)
Browse files Browse the repository at this point in the history
* TINY-10639: Safari 17 browser check

* TINY-10639: Fixed a couple tests

* TINY-10639: Update more tests

* TINY-10639: Replace Sand API

* TINY-10639: Update safari version in jenkins file and remove safari < 17 checks

* TINY-10639: Undo test changes

* TINY-10639: Fix failing webdriver tests

* TINY-10639: Fix dragster test

* TINY-10639: Fix safari webdriver tests

* TINY-10639: Testing new content to resolve some safari failures

* TINY-10639: Fix "e" character not working in safari webdriver tests

* TINY-10639: Testing with focus

* TINY-10639: Test new selector

* TINY-10639: Skip failing safari nonbreaking tests

* TINY-10639: Link Jira

* TINY-10639: Fix dragster test in Chrome

* TINY-10639: Fix Dragster test

* TINY-10639: Fix Firefox failure with inline blocks

* Revert "TINY-10639: Fix Firefox failure with inline blocks"

This reverts commit ad56f4b.

* TINY-10639: Update Safari to use latest version

* TINY-10639: Skip failing tests in firefox for TINY-10742

* TINY-10639: Fix clearData new behaviour on chrome

* TINY-10639: Skip clearData test for TINY-10743

* TINY-10639: Fix skipping tests

* TINY-10639: Skipping failing tests to be addressed in TINY-10737

---------

Co-authored-by: MitchCTiny <89239746+MitchCTiny@users.noreply.github.com>
  • Loading branch information
MitchC1999 and MitchC1999 committed Mar 10, 2024
1 parent dd3822f commit e13c27a
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 124 deletions.
3 changes: 1 addition & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ timestamps {
[ browser: 'edge', provider: 'lambdatest', buckets: 1 ],
[ browser: 'chrome', provider: 'lambdatest', os: 'macOS Sonoma', buckets: 1 ],
[ browser: 'firefox', provider: 'lambdatest', os: 'macOS Sonoma', buckets: 1 ],
// [ browser: 'safari', provider: 'lambdatest', os: 'macOS Sonoma', buckets: 1, version: '17' ], // TINY-10639: Investigate Safari 17 issues
[ browser: 'safari', provider: 'lambdatest', os: 'macOS Monterey', buckets: 1, version: '15' ],
[ browser: 'safari', provider: 'lambdatest', os: 'macOS Sonoma', buckets: 1 ]
];

def processes = [:]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,7 @@ describe('browser.dragster.datatransfer.DataTransferTest', () => {
it('TINY-9601: Files list cannot be modified', () => {
const transfer = createDataTransfer();
addAndAssertFile(transfer, testFile1, 1);
if (isSafari) {
// Safari doesn't throw a TypeError on native DataTransfer.files so verify using different method
transfer.files[0] = testFile2;
assert.deepEqual(transfer.files.item(0), testFile1, 'Should still be file 1');
} else {
assertFilesCannotBeModified(transfer);
}
assertFilesCannotBeModified(transfer);
});

it('TINY-9601: Files list cannot be modified when in protected mode', () => {
Expand All @@ -209,7 +203,8 @@ describe('browser.dragster.datatransfer.DataTransferTest', () => {
});

context('clearData', () => {
it('TINY-9601: clearData should clear data as expected', () => {
// TINY-10743: Skipping until clearData behaviour is resolved
it.skip('TINY-9601: clearData should clear data as expected', () => {
const transfer = createDataTransfer();

transfer.setData('text/plain', 'Hello');
Expand Down
43 changes: 12 additions & 31 deletions modules/sugar/src/test/ts/browser/SelectionRangeTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ UnitTest.test('WindowSelectionTest', () => {
finish: [ 0, 1, 0 ],
foffset: 'w'.length
},
safari: {
start: [ 0 ],
soffset: 2,
finish: [ 0, 1, 0 ],
foffset: 'w'.length
},
fallback: {
start: [ 0, 1, 0 ],
soffset: 'world'.length,
Expand All @@ -142,12 +148,6 @@ UnitTest.test('WindowSelectionTest', () => {
soffset: 0,
finish: [ 0 ],
foffset: 7
},
safari: {
start: [ 0, 0 ],
soffset: ''.length,
finish: [ 0 ],
foffset: 7
}
},
Situ.on(find( [ 0 ]), 0),
Expand All @@ -169,12 +169,6 @@ UnitTest.test('WindowSelectionTest', () => {
soffset: 7,
finish: [ 0 ],
foffset: 0
},
safari: {
start: [ 0 ],
soffset: 7,
finish: [ 0, 0 ],
foffset: ''.length
}
},
Situ.on(find( [ 0 ]), 7),
Expand All @@ -184,13 +178,6 @@ UnitTest.test('WindowSelectionTest', () => {
checkSelection(
'LTR selection (t I)',
{
// '<p>This <strong>world</strong> is not <strong>w<em>ha[</em>t</strong> I<br><br>]wanted</p><p><br>And even more</p>';
safari: {
start: [ 0, 3, 2 ],
soffset: ''.length,
finish: [ 0 ],
foffset: 6
},
fallback: {
start: [ 0, 3, 1 ],
soffset: 1,
Expand Down Expand Up @@ -224,6 +211,12 @@ UnitTest.test('WindowSelectionTest', () => {
start: [ 0 ],
soffset: 6
},
safari: {
finish: [ 0, 3, 1 ],
foffset: 1,
start: [ 0 ],
soffset: 6
},
spartan: {
finish: [ 0, 3, 1 ],
foffset: 1,
Expand Down Expand Up @@ -263,12 +256,6 @@ UnitTest.test('WindowSelectionTest', () => {
soffset: 0,
finish: [ 0 ],
foffset: 0
},
safari: {
start: [ 0, 0 ],
soffset: 0,
finish: [ 0, 0 ],
foffset: 0
}
},
Situ.on(find( [ 0 ]), 0 ),
Expand All @@ -283,12 +270,6 @@ UnitTest.test('WindowSelectionTest', () => {
soffset: 0,
finish: [ 0 ],
foffset: 0
},
safari: {
start: [ 0, 0 ],
soffset: 0,
finish: [ 0, 0 ],
foffset: 0
}
},
Situ.on(find( [ 0 ]), 0 ),
Expand Down
12 changes: 11 additions & 1 deletion modules/tinymce/src/core/test/ts/browser/FormatterRemoveTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, it } from '@ephox/bedrock-client';
import { PlatformDetection } from '@ephox/sand';
import { LegacyUnit, TinyApis, TinyAssertions, TinyHooks, TinySelections } from '@ephox/wrap-mcagar';
import { assert } from 'chai';

Expand All @@ -8,6 +9,8 @@ import { ZWSP } from 'tinymce/core/text/Zwsp';
import * as KeyUtils from '../module/test/KeyUtils';

describe('browser.tinymce.core.FormatterRemoveTest', () => {
const browser = PlatformDetection.detect().browser;

const hook = TinyHooks.bddSetupLight<Editor>({
indent: false,
extended_valid_elements: 'b[style],i,span[style|contenteditable|class]',
Expand Down Expand Up @@ -372,7 +375,14 @@ describe('browser.tinymce.core.FormatterRemoveTest', () => {
editor.setContent(initialContent);
LegacyUnit.setSelection(editor, 'p:nth-child(2) b', 0, 'p:last-of-type b', 3);
editor.formatter.remove('format');
TinyAssertions.assertContent(editor, initialContent);
if (browser.isSafari()) {
// Safari 17 will not select the non-editable content
// Selection only covers editable "def" and removes format correctly
const expectedContent = '<p>abc</p><p>def</p><p contenteditable="false"><b>ghj</b></p>';
TinyAssertions.assertContent(editor, expectedContent);
} else {
TinyAssertions.assertContent(editor, initialContent);
}
});

it('contentEditable: true inside contentEditable: false', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ describe('browser.tinymce.core.annotate.AnnotationStylingTest', () => {
it('TINY-8698: should have blue outline for nested editable region when selected noneditable ancestor has a comment', async () => {
const editor = hook.editor();
editor.setContent(figureImageHtml);
TinySelections.select(editor, 'img', []);
TinySelections.select(editor, 'figure.image', []);
editor.annotator.annotate('test-comment', {});
TinySelections.setCursor(editor, [ 0, 1, 0 ], 1, true);
await pAssertStyling(editor, 'figure.image', noBackgroundColor, selectedOutline, false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { beforeEach, context, describe, it } from '@ephox/bedrock-client';
import { Arr, Type } from '@ephox/katamari';
import { PlatformDetection } from '@ephox/sand';
import { TinyApis, TinyAssertions, TinyHooks } from '@ephox/wrap-mcagar';
import { assert } from 'chai';

Expand All @@ -18,11 +17,6 @@ const defaultExpectedEvents = [
];

describe('browser.tinymce.core.content.EditorContentTest', () => {
// TINY-10669: Remove this
const platform = PlatformDetection.detect();
const isSafari = platform.browser.isSafari();
const isSafariLessThan17 = isSafari && platform.browser.version.major < 17;

const toHtml = (node: AstNode): string => HtmlSerializer({}).serialize(node);

const assertContentTreeEqualToHtml = (editor: Editor, html: string, msg: string) => {
Expand Down Expand Up @@ -578,11 +572,7 @@ describe('browser.tinymce.core.content.EditorContentTest', () => {
const editor = hook.editor();
editor.setContent('<p><iframe><p>test</p></iframe></p>');
const content = editor.getContent();
// TINY-10669: Remove this check
const expected = isSafariLessThan17
? '<p><iframe sandbox="">&lt;p&gt;test&lt;/p&gt;</iframe></p>'
: '<p><iframe sandbox=""><p>test</p></iframe></p>';
assert.equal(content, expected, 'getContent should not error when there is iframes with child nodes in content');
assert.equal(content, '<p><iframe sandbox=""><p>test</p></iframe></p>', 'getContent should not error when there is iframes with child nodes in content');
});

it('getContent text with unsanitized content should get text from unsanitized content', () => {
Expand Down Expand Up @@ -619,11 +609,7 @@ describe('browser.tinymce.core.content.EditorContentTest', () => {
it('TINY-10305: setContent html should sanitize content that can cause mXSS via ZWNBSP trimming', () => {
const editor = hook.editor();
editor.setContent('<p>test</p><!--\ufeff><iframe onload=alert(document.domain)>-></body>-->');
// TINY-10669: Remove this check
const expected = isSafariLessThan17
? '<p>test</p><!----><p><iframe sandbox="">-&gt;&lt;/body&gt;--&gt;&lt;/body&gt;</iframe></p>'
: '<p>test</p><!---->';
TinyAssertions.assertRawContent(editor, expected);
TinyAssertions.assertRawContent(editor, '<p>test</p><!---->');
});

it('TINY-10305: setContent tree should sanitize content that can cause mXSS via ZWNBSP trimming', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { context, describe, it } from '@ephox/bedrock-client';
import { Arr } from '@ephox/katamari';
import { PlatformDetection } from '@ephox/sand';
import { TinyApis, TinyAssertions, TinyHooks } from '@ephox/wrap-mcagar';
import { assert } from 'chai';

import Editor from 'tinymce/core/api/Editor';

describe('browser.tinymce.core.content.EditorGetContentRawTest', () => {
// TINY-10669: Remove this
const platform = PlatformDetection.detect();
const isSafariLessThan17 = platform.browser.isSafari() && platform.browser.version.major < 17;

const hook = TinyHooks.bddSetupLight<Editor>({
base_url: '/project/tinymce/js/tinymce'
}, []);
Expand Down Expand Up @@ -51,8 +46,7 @@ describe('browser.tinymce.core.content.EditorGetContentRawTest', () => {
TinyApis(editor).setRawContent(initial);
assert.strictEqual(editor.getContent({ format: 'raw' }), '<p>test0</p><plaintext></plaintext>', 'Should be expected html');
// TINY-10305: Modern browsers add a closing plaintext tag to end of body. Safari escapes text nodes within <plaintext>.
TinyAssertions.assertRawContent(editor,
isSafariLessThan17 ? '<p>test0</p><plaintext>te\uFEFFst1 test2&lt;p&gt;te\uFEFFst3&lt;/p&gt;</plaintext>' : `${initial}</plaintext>`);
TinyAssertions.assertRawContent(editor, `${initial}</plaintext>`);
});

context('Content XSS', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { context, describe, it } from '@ephox/bedrock-client';
import { PlatformDetection } from '@ephox/sand';
import { TinyAssertions, TinyHooks, TinySelections, TinyState } from '@ephox/wrap-mcagar';
import { assert } from 'chai';

Expand All @@ -9,10 +8,6 @@ import { EditorEvent } from 'tinymce/core/api/util/EventDispatcher';
import * as InsertContent from 'tinymce/core/content/InsertContent';

describe('browser.tinymce.core.content.InsertContentTest', () => {
// TINY-10669: Remove this
const platform = PlatformDetection.detect();
const isSafariLessThan17 = platform.browser.isSafari() && platform.browser.version.major < 17;

const hook = TinyHooks.bddSetupLight<Editor>({
add_unload_trigger: false,
disable_nodechange: true,
Expand Down Expand Up @@ -845,9 +840,7 @@ describe('browser.tinymce.core.content.InsertContentTest', () => {
TinySelections.setCursor(editor, [ 0 ], 0);
editor.insertContent('<!--\ufeff><iframe onload=alert(document.domain)>-></body>-->');
// TINY-10305: Safari escapes text nodes within <iframe>.
TinyAssertions.assertRawContent(editor, isSafariLessThan17
? '<p><!----><iframe sandbox="">-&gt;&lt;/body&gt;--&gt;&lt;span id="mce_marker" data-mce-type="bookmark"&gt;&amp;#xFEFF;&lt;/span&gt;&lt;/body&gt;</iframe>initial</p>'
: '<p><!---->initial</p>');
TinyAssertions.assertRawContent(editor, '<p><!---->initial</p>');
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { context, describe, it } from '@ephox/bedrock-client';
import { PlatformDetection } from '@ephox/sand';
import { LegacyUnit, TinyAssertions, TinyHooks, TinySelections } from '@ephox/wrap-mcagar';
import { assert } from 'chai';

Expand All @@ -10,6 +11,9 @@ import * as CaretContainer from 'tinymce/core/caret/CaretContainer';
import * as Zwsp from 'tinymce/core/text/Zwsp';

describe('browser.tinymce.core.dom.SelectionTest', () => {
const platform = PlatformDetection.detect();
const isSafari = platform.browser.isSafari();

const hook = TinyHooks.bddSetupLight<Editor>({
add_unload_trigger: false,
entities: 'raw',
Expand Down Expand Up @@ -1365,7 +1369,8 @@ describe('browser.tinymce.core.dom.SelectionTest', () => {
soffset: 1,
fpath: [ 1, 0 ],
foffset: 1,
expected: false
// TINY-10639: Safari does not allow selection over non-editable content
expected: isSafari
}));

it('TINY-9477: isEditable on selected noneditable table cells should be true since parent is editable', testIsEditableSelection({
Expand Down
6 changes: 1 addition & 5 deletions modules/tinymce/src/core/test/ts/browser/dom/TrimBodyTest.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { context, describe, it } from '@ephox/bedrock-client';
import { Arr } from '@ephox/katamari';
import { PlatformDetection } from '@ephox/sand';
import { assert } from 'chai';

import * as TrimBody from 'tinymce/core/dom/TrimBody';

describe('browser.tinymce.core.dom.TrimBodyTest', () => {
const isSafari = PlatformDetection.detect().browser.isSafari();

context('trim', () => {
it('trim should trim body containing trimmmable nodes', () => {
const tempAttrs = [ 'data-mce-selected' ];
Expand Down Expand Up @@ -180,8 +177,7 @@ describe('browser.tinymce.core.dom.TrimBodyTest', () => {
unescapedText.innerHTML = `<p>Test</p><${plaintext}>Test<p>Test</p>`;
TrimBody.emptyUnescapedZwspTexts(unescapedText);
// TINY-10305: Safari escapes text nodes within <plaintext>.
assert.strictEqual(unescapedText.innerHTML,
isSafari ? `<p>Test</p><${plaintext}>Test&lt;p&gt;Test&lt;/p&gt;</${plaintext}>` : `<p>Test</p><${plaintext}>Test<p>Test</p></${plaintext}>`);
assert.strictEqual(unescapedText.innerHTML, `<p>Test</p><${plaintext}>Test<p>Test</p></${plaintext}>`);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { context, describe, it } from '@ephox/bedrock-client';
import { Arr, Fun, Obj } from '@ephox/katamari';
import { PlatformDetection } from '@ephox/sand';
import { assert } from 'chai';

import Env from 'tinymce/core/api/Env';
Expand All @@ -17,7 +16,6 @@ interface ParseTestResult {
}

describe('browser.tinymce.core.html.DomParserTest', () => {
const browser = PlatformDetection.detect().browser;
const schema = Schema({ valid_elements: '*[class|title]' });
const serializer = HtmlSerializer({}, schema);

Expand Down Expand Up @@ -772,7 +770,7 @@ describe('browser.tinymce.core.html.DomParserTest', () => {

assert.equal(
serializer.serialize(DomParser(scenario.settings).parse('<iframe><textarea></iframe><img src="a" onerror="alert(document.domain)" />')),
browser.isSafari() || !scenario.isSanitizeEnabled ? '<iframe><textarea></iframe><img src="a">' : '<img src="a">'
scenario.isSanitizeEnabled ? '<img src="a">' : '<iframe><textarea></iframe><img src="a">'
);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { context, describe, it } from '@ephox/bedrock-client';
import { PlatformDetection } from '@ephox/sand';
import { assert } from 'chai';

import Schema from 'tinymce/core/api/html/Schema';
import { getSanitizer, MimeType } from 'tinymce/core/html/Sanitization';

describe('browser.tinymce.core.html.SanitizationTest', () => {
context('Sanitize html', () => {
const isSafari = PlatformDetection.detect().browser.isSafari();

const testHtmlSanitizer = (testCase: { input: string; expected: string; mimeType: MimeType; sanitize?: boolean }) => {
const sanitizer = getSanitizer({ sanitize: testCase.sanitize ?? true }, Schema());

Expand All @@ -22,14 +19,14 @@ describe('browser.tinymce.core.html.SanitizationTest', () => {
it('Sanitize iframe HTML', () => testHtmlSanitizer({
input: '<iframe src="x"><script>alert(1)</script></iframe><iframe src="javascript:alert(1)"></iframe>',
// Safari seems to encode the contents of iframes
expected: isSafari ? '<iframe src="x">&lt;script&gt;alert(1)&lt;/script&gt;</iframe><iframe></iframe>' : '<iframe></iframe>',
expected: '<iframe></iframe>',
mimeType: 'text/html'
}));

it('Disabled sanitization of iframe HTML', () => testHtmlSanitizer({
input: '<iframe src="x"><script>alert(1)</script></iframe><iframe src="javascript:alert(1)"></iframe>',
// Safari seems to encode the contents of iframes
expected: isSafari ? '<iframe src="x">&lt;script&gt;alert(1)&lt;/script&gt;</iframe><iframe></iframe>' : '<iframe src="x"><script>alert(1)</script></iframe><iframe></iframe>',
expected: '<iframe src="x"><script>alert(1)</script></iframe><iframe></iframe>',
mimeType: 'text/html',
sanitize: false
}));
Expand Down
Loading

0 comments on commit e13c27a

Please sign in to comment.