mirror of
https://github.com/LamGC/wp-asciiplayer.git
synced 2026-11-26 20:55:48 +00:00
Improve automatic previews and toolbar terminal sizing (1.2.1)
This commit is contained in:
+5
-4
@@ -9,15 +9,16 @@
|
|||||||
GitHub 源码 ZIP 需要先构建,不能直接当发行包安装。构建方法见 [SOURCE.md](SOURCE.md)。
|
GitHub 源码 ZIP 需要先构建,不能直接当发行包安装。构建方法见 [SOURCE.md](SOURCE.md)。
|
||||||
要求 WordPress 6.3+、PHP 7.4+;具体测试版本见仓库 CI。
|
要求 WordPress 6.3+、PHP 7.4+;具体测试版本见仓库 CI。
|
||||||
|
|
||||||
插入「Asciicast Player」区块,粘贴录制文件的 HTTP(S) URL,应用后即可在编辑器内播放、
|
插入「Asciicast Player」区块,粘贴录制文件的 HTTP(S) URL,停止输入约半秒后会自动加载预览;也可以点击「Apply URL」立即加载。之后即可在编辑器内播放、
|
||||||
暂停和拖动。「Display」面板提供展示宽度预设、自定义宽度(例如 `480px`、`65%`)以及左、中、右对齐;
|
暂停和拖动。「Display」面板提供展示宽度预设、自定义宽度(例如 `480px`、`65%`)以及左、中、右对齐;
|
||||||
展示宽度会限制在当前页面可用空间内。点击播放器下方即可添加描述文字。
|
展示宽度会限制在当前页面可用空间内。点击播放器下方即可添加描述文字。
|
||||||
|
|
||||||
「Terminal size」与展示大小分别控制:Columns / Rows 留空时,使用 cast 文件记录的终端尺寸,
|
在区块上方浮动工具栏点击「Terminal size」可快速调整终端行列数;侧边栏的同名折叠面板也保留,两处设置实时同步。
|
||||||
|
终端尺寸与展示大小分别控制:Columns / Rows 留空时,使用 cast 文件记录的终端尺寸,
|
||||||
并跟随录制中的 resize 事件。只有需要改变终端网格时才覆盖行列数,点击「Use recording size」可恢复。
|
并跟随录制中的 resize 事件。只有需要改变终端网格时才覆盖行列数,点击「Use recording size」可恢复。
|
||||||
展示宽度与 `fit: width` 只缩放画面,不会修改终端行列数;覆盖网格可能影响录屏排版或裁切内容。
|
展示宽度与 `fit: width` 只缩放画面,不会修改终端行列数;覆盖网格可能影响录屏排版或裁切内容。
|
||||||
主题、速度、循环、控制栏、起始时间和空闲压缩等选项仍在区块设置中调整。
|
主题、速度、循环、控制栏、起始时间和空闲压缩等选项仍在区块设置中调整。
|
||||||
保存文章或页面后,前台使用同一播放器。重新打开已有区块时点击「Load preview」加载预览;
|
保存文章或页面后,前台使用同一播放器。重新打开已有区块时,只要已有有效 URL 就自动加载预览;
|
||||||
编辑预览不会自动播放,前台自动播放设置仍会保留。区块插入器使用本地静态示例,不请求录制文件。
|
编辑预览不会自动播放,前台自动播放设置仍会保留。区块插入器使用本地静态示例,不请求录制文件。
|
||||||
播放器增加了局部样式隔离,避免常见主题的代码块边框、阴影和字体设置干扰终端;键盘焦点提示仍保留。
|
播放器增加了局部样式隔离,避免常见主题的代码块边框、阴影和字体设置干扰终端;键盘焦点提示仍保留。
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ URL 必须指向录制文件(例如 `.cast`),不能直接使用分享页
|
|||||||
旧 `ap_use_local_resources` 开关不再使用。没有统计追踪或后台远程 API 请求。
|
旧 `ap_use_local_resources` 开关不再使用。没有统计追踪或后台远程 API 请求。
|
||||||
|
|
||||||
你选择的录制文件会由读者浏览器直接请求;外部文件主机可能收到 IP、浏览器请求信息和
|
你选择的录制文件会由读者浏览器直接请求;外部文件主机可能收到 IP、浏览器请求信息和
|
||||||
依浏览器/站点策略发送的来源信息。应用 URL 或点击加载预览时,编辑器也会发起这类请求。
|
依浏览器/站点策略发送的来源信息。编辑器存在有效 URL 时也会自动发起这类请求,包括重新打开已保存的区块。
|
||||||
请使用可信主机,发布前检查录屏是否包含终端里的敏感信息。外部主机适用其自身隐私政策。
|
请使用可信主机,发布前检查录屏是否包含终端里的敏感信息。外部主机适用其自身隐私政策。
|
||||||
|
|
||||||
## 开发与许可
|
## 开发与许可
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ site and theme; CI tests the versions listed in `.github/workflows/ci.yml`.
|
|||||||
## Block editor
|
## Block editor
|
||||||
|
|
||||||
1. Insert **Asciicast Player**.
|
1. Insert **Asciicast Player**.
|
||||||
2. Paste an HTTP(S) recording-file URL (for example a `.cast` file), then apply it.
|
2. Paste an HTTP(S) recording-file URL (for example a `.cast` file). The preview loads after a short pause; **Apply URL** loads it immediately.
|
||||||
3. Play, pause and seek in the editor. **Display** offers width presets or a custom
|
3. Play, pause and seek in the editor. **Display** offers width presets or a custom
|
||||||
CSS length (for example `480px` or `65%`), plus left/center/right alignment.
|
CSS length (for example `480px` or `65%`), plus left/center/right alignment.
|
||||||
The width stays within the available space. Add a caption below the player.
|
The width stays within the available space. Add a caption below the player.
|
||||||
4. **Terminal size** is separate: leave Columns and Rows blank to use the cast
|
4. Use **Terminal size** in the floating block toolbar for quick Columns/Rows
|
||||||
|
edits, or expand the **Terminal size** sidebar panel. Both edit the same values.
|
||||||
|
Terminal size is separate from display width: leave Columns and Rows blank to use the cast
|
||||||
file's dimensions and recorded resize events. Override either axis only when
|
file's dimensions and recorded resize events. Override either axis only when
|
||||||
intentional; use **Use recording size** to clear both. Display width and
|
intentional; use **Use recording size** to clear both. Display width and
|
||||||
`fit: width` scale the existing grid without changing terminal columns.
|
`fit: width` scale the existing grid without changing terminal columns.
|
||||||
@@ -27,8 +29,9 @@ site and theme; CI tests the versions listed in `.github/workflows/ci.yml`.
|
|||||||
from the remaining block settings.
|
from the remaining block settings.
|
||||||
6. Save the post or page; the same locally bundled player is used on the front end.
|
6. Save the post or page; the same locally bundled player is used on the front end.
|
||||||
|
|
||||||
Existing saved blocks show a **Load preview** action on reopening the editor.
|
Existing saved blocks load their valid recording URL automatically on reopening
|
||||||
This keeps external recordings from loading until you choose to preview them.
|
the editor. Typed URL changes are debounced for 500ms; empty or invalid URLs do
|
||||||
|
not start a recording request.
|
||||||
Preview does not autoplay even when front-end autoplay is enabled.
|
Preview does not autoplay even when front-end autoplay is enabled.
|
||||||
The inserter preview is a local static example and never loads a recording.
|
The inserter preview is a local static example and never loads a recording.
|
||||||
|
|
||||||
@@ -68,7 +71,7 @@ No analytics or background remote API calls are added.
|
|||||||
A recording URL you choose is fetched directly by the visitor's browser. Its host
|
A recording URL you choose is fetched directly by the visitor's browser. Its host
|
||||||
can receive the visitor's IP address, browser request metadata and possibly a
|
can receive the visitor's IP address, browser request metadata and possibly a
|
||||||
referrer, according to browser/site policy. Editor previews have the same effect
|
referrer, according to browser/site policy. Editor previews have the same effect
|
||||||
when you apply a URL or click **Load preview**. Choose a trusted host and review
|
automatically when a valid URL is present, including when reopening saved blocks. Choose a trusted host and review
|
||||||
recordings for sensitive terminal output before publishing them. The host's own
|
recordings for sensitive terminal output before publishing them. The host's own
|
||||||
privacy policy applies; the plugin cannot make an external recording private.
|
privacy policy applies; the plugin cannot make an external recording private.
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: Asciicast Player
|
* Plugin Name: Asciicast Player
|
||||||
* Plugin URI: https://github.com/LamGC/wp-asciiplayer
|
* Plugin URI: https://github.com/LamGC/wp-asciiplayer
|
||||||
* Description: Add interactive terminal recordings to posts and pages with a block or shortcode.
|
* Description: Add interactive terminal recordings to posts and pages with a block or shortcode.
|
||||||
* Version: 1.2.0
|
* Version: 1.2.1
|
||||||
* Requires at least: 6.3
|
* Requires at least: 6.3
|
||||||
* Requires PHP: 7.4
|
* Requires PHP: 7.4
|
||||||
* Author: LamGC
|
* Author: LamGC
|
||||||
@@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERSION = '1.2.0';
|
const VERSION = '1.2.1';
|
||||||
const PLUGIN_FILE = __FILE__;
|
const PLUGIN_FILE = __FILE__;
|
||||||
const SHORTCODE = 'asciiplayer';
|
const SHORTCODE = 'asciiplayer';
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "lamgc/asciiplayer",
|
"name": "lamgc/asciiplayer",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"title": "Asciicast Player",
|
"title": "Asciicast Player",
|
||||||
"category": "media",
|
"category": "media",
|
||||||
"icon": "editor-code",
|
"icon": "editor-code",
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "wp-asciiplayer",
|
"name": "wp-asciiplayer",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "wp-asciiplayer",
|
"name": "wp-asciiplayer",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"asciinema-player": "3.17.0"
|
"asciinema-player": "3.17.0"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wp-asciiplayer",
|
"name": "wp-asciiplayer",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Native WordPress asciicast block with real playback previews and compatible shortcodes",
|
"description": "Native WordPress asciicast block with real playback previews and compatible shortcodes",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
+8
-3
@@ -4,7 +4,7 @@ Tags: asciicast, asciiplayer, asciinema, terminal, block
|
|||||||
Requires at least: 6.3
|
Requires at least: 6.3
|
||||||
Tested up to: 7.1
|
Tested up to: 7.1
|
||||||
Requires PHP: 7.4
|
Requires PHP: 7.4
|
||||||
Stable tag: 1.2.0
|
Stable tag: 1.2.1
|
||||||
License: GPL-3.0-only
|
License: GPL-3.0-only
|
||||||
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
@@ -17,14 +17,14 @@ Insert an Asciicast Player block, apply a recording-file URL, and play it direct
|
|||||||
* Locally bundled asciinema-player, JavaScript, CSS and WebAssembly.
|
* Locally bundled asciinema-player, JavaScript, CSS and WebAssembly.
|
||||||
* Native block-editor controls and iframe-aware interactive preview.
|
* Native block-editor controls and iframe-aware interactive preview.
|
||||||
* Compatible shortcode rendering in posts and pages.
|
* Compatible shortcode rendering in posts and pages.
|
||||||
* Explicit editor preview loading and clear loading/failure feedback.
|
* Automatic preview loading for valid URLs, debounced editing, and clear loading/failure feedback.
|
||||||
* No account, analytics, remote proxy, custom post type or extra upload permissions.
|
* No account, analytics, remote proxy, custom post type or extra upload permissions.
|
||||||
|
|
||||||
The source and reproducible build instructions are included in the ZIP and available at https://github.com/LamGC/wp-asciiplayer . Third-party licenses are in THIRD-PARTY-NOTICES.md and licenses/.
|
The source and reproducible build instructions are included in the ZIP and available at https://github.com/LamGC/wp-asciiplayer . Third-party licenses are in THIRD-PARTY-NOTICES.md and licenses/.
|
||||||
|
|
||||||
= External recordings and privacy =
|
= External recordings and privacy =
|
||||||
|
|
||||||
The plugin itself uses no external runtime service. When you choose an external recording URL, the visitor's browser requests that URL directly. The host may receive IP address, browser request metadata and a referrer according to browser/site policy. Applying a URL or loading a preview in the editor makes the same request. Choose a trusted host and consult its privacy policy. Use a same-site HTTPS recording URL to avoid third-party requests. Review terminal output for sensitive data before publishing.
|
The plugin itself uses no external runtime service. When you choose an external recording URL, the visitor's browser requests that URL directly. The host may receive IP address, browser request metadata and a referrer according to browser/site policy. A valid URL automatically loads the editor preview and makes the same request, including when reopening a saved block. Choose a trusted host and consult its privacy policy. Use a same-site HTTPS recording URL to avoid third-party requests. Review terminal output for sensitive data before publishing.
|
||||||
|
|
||||||
== Installation ==
|
== Installation ==
|
||||||
|
|
||||||
@@ -54,6 +54,11 @@ Existing shortcodes work in the Classic Editor. The new visual controls and inli
|
|||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 1.2.1 =
|
||||||
|
* Automatically load saved recording previews without enabling playback autoplay.
|
||||||
|
* Debounce recording URL edits; retain immediate apply, retry and request cleanup.
|
||||||
|
* Add terminal Columns/Rows and reset controls to the floating block toolbar, synchronized with the collapsed sidebar panel.
|
||||||
|
|
||||||
= 1.2.0 =
|
= 1.2.0 =
|
||||||
* Add responsive display-width presets/custom lengths, left/center/right placement and captions.
|
* Add responsive display-width presets/custom lengths, left/center/right placement and captions.
|
||||||
* Preserve recorded terminal dimensions and resize events by default; expose optional row/column overrides.
|
* Preserve recorded terminal dimensions and resize events by default; expose optional row/column overrides.
|
||||||
|
|||||||
+55
-20
@@ -1,19 +1,46 @@
|
|||||||
import { BlockAlignmentToolbar, BlockControls, InspectorControls, RichText, useBlockProps } from '@wordpress/block-editor';
|
import { BlockAlignmentToolbar, BlockControls, InspectorControls, RichText, useBlockProps } from '@wordpress/block-editor';
|
||||||
import { Button, Notice, PanelBody, Placeholder, RangeControl, SelectControl, TextControl, ToggleControl } from '@wordpress/components';
|
import { Button, Dropdown, Notice, PanelBody, Placeholder, RangeControl, SelectControl, TextControl, ToggleControl, ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
||||||
import { useEffect, useState } from '@wordpress/element';
|
import { useEffect, useState } from '@wordpress/element';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { finiteNumber, normalizeDisplayAlign, normalizeSource, normalizeWidth, terminalDimension } from './options.js';
|
import { finiteNumber, normalizeDisplayAlign, normalizeSource, normalizeWidth, terminalDimension } from './options.js';
|
||||||
import Preview from './preview.js';
|
import Preview from './preview.js';
|
||||||
|
|
||||||
|
/** One shared set of dimension controls in the block toolbar and settings sidebar. */
|
||||||
|
function TerminalSizeControls( { attributes, setAttributes } ) {
|
||||||
|
return <>
|
||||||
|
<div className="asciiplayer-editor__dimension-fields">
|
||||||
|
<TextControl label={ __( 'Columns', 'wp-asciiplayer' ) } type="number" min="1" max="1000" step="1" value={ attributes.cols ?? '' } placeholder={ __( 'From recording', 'wp-asciiplayer' ) } onChange={ ( value ) => setAttributes( { cols: terminalDimension( value ) } ) } />
|
||||||
|
<TextControl label={ __( 'Rows', 'wp-asciiplayer' ) } type="number" min="1" max="1000" step="1" value={ attributes.rows ?? '' } placeholder={ __( 'From recording', 'wp-asciiplayer' ) } onChange={ ( value ) => setAttributes( { rows: terminalDimension( value ) } ) } />
|
||||||
|
</div>
|
||||||
|
<p className="asciiplayer-editor__hint">{ __( 'Leave blank to use the cast file’s terminal size and recorded resize events. These overrides change the character grid, not the display width, and may alter or crop the layout.', 'wp-asciiplayer' ) }</p>
|
||||||
|
<Button variant="secondary" onClick={ () => setAttributes( { cols: undefined, rows: undefined } ) }>{ __( 'Use recording size', 'wp-asciiplayer' ) }</Button>
|
||||||
|
</>;
|
||||||
|
}
|
||||||
|
|
||||||
export default function Edit( { attributes, setAttributes, isSelected } ) {
|
export default function Edit( { attributes, setAttributes, isSelected } ) {
|
||||||
const { source, theme, speed, loop, controls, fit, startAt, idleTimeLimit, autoPlay, preload, width, caption, displayAlign, cols, rows } = attributes;
|
const { source, theme, speed, loop, controls, fit, startAt, idleTimeLimit, autoPlay, preload, width, caption, displayAlign } = attributes;
|
||||||
const [ draftSource, setDraftSource ] = useState( source );
|
const [ draftSource, setDraftSource ] = useState( source );
|
||||||
const [ approvedSource, setApprovedSource ] = useState( '' );
|
|
||||||
const [ urlError, setUrlError ] = useState( false );
|
const [ urlError, setUrlError ] = useState( false );
|
||||||
const [ attempt, setAttempt ] = useState( 0 );
|
const [ attempt, setAttempt ] = useState( 0 );
|
||||||
const [ draftWidth, setDraftWidth ] = useState( width );
|
const [ draftWidth, setDraftWidth ] = useState( width );
|
||||||
useEffect( () => setDraftWidth( width ), [ width ] );
|
useEffect( () => setDraftWidth( width ), [ width ] );
|
||||||
useEffect( () => setDraftSource( source ), [ source ] );
|
useEffect( () => {
|
||||||
|
setDraftSource( source );
|
||||||
|
setUrlError( Boolean( source.trim() ) && ! normalizeSource( source ) );
|
||||||
|
}, [ source ] );
|
||||||
|
// Saved/undone sources load immediately. Typed changes wait until the user
|
||||||
|
// pauses, and submitting the form applies the same URL without that delay.
|
||||||
|
useEffect( () => {
|
||||||
|
if ( attributes.isExample || draftSource === source ) return undefined;
|
||||||
|
const timer = setTimeout( () => {
|
||||||
|
const next = normalizeSource( draftSource );
|
||||||
|
setUrlError( Boolean( draftSource.trim() ) && ! next );
|
||||||
|
if ( next || ! draftSource.trim() ) setAttributes( { source: next } );
|
||||||
|
}, 500 );
|
||||||
|
return () => clearTimeout( timer );
|
||||||
|
}, [ draftSource, source, attributes.isExample, setAttributes ] );
|
||||||
|
const previewSource = normalizeSource( source );
|
||||||
|
const showPreview = previewSource && previewSource === normalizeSource( draftSource );
|
||||||
const blockProps = useBlockProps( { className: 'asciiplayer-editor' } );
|
const blockProps = useBlockProps( { className: 'asciiplayer-editor' } );
|
||||||
const applySource = ( event ) => {
|
const applySource = ( event ) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -22,7 +49,6 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
|
|||||||
if ( ! next ) return;
|
if ( ! next ) return;
|
||||||
setAttributes( { source: next } );
|
setAttributes( { source: next } );
|
||||||
setDraftSource( next );
|
setDraftSource( next );
|
||||||
setApprovedSource( next );
|
|
||||||
setAttempt( ( current ) => current + 1 );
|
setAttempt( ( current ) => current + 1 );
|
||||||
};
|
};
|
||||||
const themes = [
|
const themes = [
|
||||||
@@ -48,25 +74,36 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BlockControls group="other"><BlockAlignmentToolbar value={ placement } controls={ [ 'left', 'center', 'right' ] } onChange={ ( value ) => setAttributes( { displayAlign: normalizeDisplayAlign( value ) } ) } /></BlockControls>
|
<BlockControls group="other">
|
||||||
|
<BlockAlignmentToolbar value={ placement } controls={ [ 'left', 'center', 'right' ] } onChange={ ( value ) => setAttributes( { displayAlign: normalizeDisplayAlign( value ) } ) } />
|
||||||
|
<ToolbarGroup>
|
||||||
|
<Dropdown contentClassName="asciiplayer-terminal-popover" popoverProps={ { placement: 'bottom-start' } } renderToggle={ ( { isOpen, onToggle } ) => (
|
||||||
|
<ToolbarButton icon="editor-table" label={ __( 'Terminal size', 'wp-asciiplayer' ) } aria-expanded={ isOpen } onClick={ onToggle } />
|
||||||
|
) } renderContent={ ( { onClose } ) => (
|
||||||
|
<div className="asciiplayer-terminal-popover__content" role="dialog" aria-label={ __( 'Terminal size', 'wp-asciiplayer' ) }>
|
||||||
|
<p><strong>{ __( 'Terminal size (columns × rows)', 'wp-asciiplayer' ) }</strong></p>
|
||||||
|
<TerminalSizeControls attributes={ attributes } setAttributes={ setAttributes } />
|
||||||
|
<Button variant="tertiary" onClick={ onClose }>{ __( 'Close', 'wp-asciiplayer' ) }</Button>
|
||||||
|
</div>
|
||||||
|
) } />
|
||||||
|
</ToolbarGroup>
|
||||||
|
</BlockControls>
|
||||||
<InspectorControls>
|
<InspectorControls>
|
||||||
|
<PanelBody title={ __( 'Terminal size', 'wp-asciiplayer' ) } initialOpen={ false }>
|
||||||
|
<TerminalSizeControls attributes={ attributes } setAttributes={ setAttributes } />
|
||||||
|
</PanelBody>
|
||||||
<PanelBody title={ __( 'Display', 'wp-asciiplayer' ) }>
|
<PanelBody title={ __( 'Display', 'wp-asciiplayer' ) }>
|
||||||
<SelectControl label={ __( 'Player width', 'wp-asciiplayer' ) } value={ customWidth || ! widthPresets.includes( width ) ? 'custom' : width } options={ widthOptions } onChange={ ( value ) => { setCustomWidth( value === 'custom' ); if ( value !== 'custom' ) setAttributes( { width: value } ); } } />
|
<SelectControl label={ __( 'Player width', 'wp-asciiplayer' ) } value={ customWidth || ! widthPresets.includes( width ) ? 'custom' : width } options={ widthOptions } onChange={ ( value ) => { setCustomWidth( value === 'custom' ); if ( value !== 'custom' ) setAttributes( { width: value } ); } } />
|
||||||
{ ( customWidth || ! widthPresets.includes( width ) ) && <TextControl label={ __( 'Custom width', 'wp-asciiplayer' ) } value={ draftWidth } help={ widthValid ? __( 'Use a CSS length, such as 480px or 65%. The player stays within its available space.', 'wp-asciiplayer' ) : __( 'Enter a positive width with a unit, such as 480px or 65%. The last valid width is kept.', 'wp-asciiplayer' ) } aria-invalid={ ! widthValid } onChange={ ( value ) => { setDraftWidth( value ); if ( value.trim() && normalizeWidth( value ) === value.trim() && parseFloat( value ) > 0 ) setAttributes( { width: value.trim() } ); } } /> }
|
{ ( customWidth || ! widthPresets.includes( width ) ) && <TextControl label={ __( 'Custom width', 'wp-asciiplayer' ) } value={ draftWidth } help={ widthValid ? __( 'Use a CSS length, such as 480px or 65%. The player stays within its available space.', 'wp-asciiplayer' ) : __( 'Enter a positive width with a unit, such as 480px or 65%. The last valid width is kept.', 'wp-asciiplayer' ) } aria-invalid={ ! widthValid } onChange={ ( value ) => { setDraftWidth( value ); if ( value.trim() && normalizeWidth( value ) === value.trim() && parseFloat( value ) > 0 ) setAttributes( { width: value.trim() } ); } } /> }
|
||||||
<SelectControl label={ __( 'Display alignment', 'wp-asciiplayer' ) } value={ placement } options={ [ { label: __( 'Left', 'wp-asciiplayer' ), value: 'left' }, { label: __( 'Center', 'wp-asciiplayer' ), value: 'center' }, { label: __( 'Right', 'wp-asciiplayer' ), value: 'right' } ] } onChange={ ( value ) => setAttributes( { displayAlign: value } ) } />
|
<SelectControl label={ __( 'Display alignment', 'wp-asciiplayer' ) } value={ placement } options={ [ { label: __( 'Left', 'wp-asciiplayer' ), value: 'left' }, { label: __( 'Center', 'wp-asciiplayer' ), value: 'center' }, { label: __( 'Right', 'wp-asciiplayer' ), value: 'right' } ] } onChange={ ( value ) => setAttributes( { displayAlign: value } ) } />
|
||||||
<p>{ __( 'Display width scales the recording without changing its terminal columns or rows. Add a caption directly below the player.', 'wp-asciiplayer' ) }</p>
|
<p>{ __( 'Display width scales the recording without changing its terminal columns or rows. Add a caption directly below the player.', 'wp-asciiplayer' ) }</p>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
<PanelBody title={ __( 'Terminal size', 'wp-asciiplayer' ) } initialOpen={ false }>
|
|
||||||
<p>{ __( 'Leave blank to use the size recorded in the cast file, including recorded resize events. Overrides change the terminal grid and can alter or crop the recording’s layout.', 'wp-asciiplayer' ) }</p>
|
|
||||||
<TextControl label={ __( 'Columns', 'wp-asciiplayer' ) } type="number" min="1" max="1000" step="1" value={ cols ?? '' } placeholder={ __( 'From recording', 'wp-asciiplayer' ) } onChange={ ( value ) => setAttributes( { cols: terminalDimension( value ) } ) } />
|
|
||||||
<TextControl label={ __( 'Rows', 'wp-asciiplayer' ) } type="number" min="1" max="1000" step="1" value={ rows ?? '' } placeholder={ __( 'From recording', 'wp-asciiplayer' ) } onChange={ ( value ) => setAttributes( { rows: terminalDimension( value ) } ) } />
|
|
||||||
<Button variant="secondary" onClick={ () => setAttributes( { cols: undefined, rows: undefined } ) }>{ __( 'Use recording size', 'wp-asciiplayer' ) }</Button>
|
|
||||||
</PanelBody>
|
|
||||||
<PanelBody title={ __( 'Playback', 'wp-asciiplayer' ) }>
|
<PanelBody title={ __( 'Playback', 'wp-asciiplayer' ) }>
|
||||||
<RangeControl label={ __( 'Playback speed', 'wp-asciiplayer' ) } value={ speed } min={ 0.25 } max={ Math.max( 8, speed ) } step={ 0.25 } onChange={ ( value ) => setAttributes( { speed: finiteNumber( value, 1, 0.01, 100 ) } ) } />
|
<RangeControl label={ __( 'Playback speed', 'wp-asciiplayer' ) } value={ speed } min={ 0.25 } max={ Math.max( 8, speed ) } step={ 0.25 } onChange={ ( value ) => setAttributes( { speed: finiteNumber( value, 1, 0.01, 100 ) } ) } />
|
||||||
<ToggleControl label={ __( 'Loop playback', 'wp-asciiplayer' ) } checked={ loop } onChange={ ( value ) => setAttributes( { loop: value } ) } />
|
<ToggleControl label={ __( 'Loop playback', 'wp-asciiplayer' ) } checked={ loop } onChange={ ( value ) => setAttributes( { loop: value } ) } />
|
||||||
<ToggleControl label={ __( 'Autoplay on published page', 'wp-asciiplayer' ) } help={ __( 'The editor preview always waits for you to press play.', 'wp-asciiplayer' ) } checked={ autoPlay } onChange={ ( value ) => setAttributes( { autoPlay: value } ) } />
|
<ToggleControl label={ __( 'Autoplay on published page', 'wp-asciiplayer' ) } help={ __( 'The editor preview always waits for you to press play.', 'wp-asciiplayer' ) } checked={ autoPlay } onChange={ ( value ) => setAttributes( { autoPlay: value } ) } />
|
||||||
<ToggleControl label={ __( 'Preload on published page', 'wp-asciiplayer' ) } help={ __( 'Loads the recording before the visitor presses play. The editor always preloads after you apply the URL.', 'wp-asciiplayer' ) } checked={ preload } onChange={ ( value ) => setAttributes( { preload: value } ) } />
|
<ToggleControl label={ __( 'Preload on published page', 'wp-asciiplayer' ) } help={ __( 'Loads the recording before the visitor presses play. The editor preview always preloads a valid recording URL.', 'wp-asciiplayer' ) } checked={ preload } onChange={ ( value ) => setAttributes( { preload: value } ) } />
|
||||||
<TextControl label={ __( 'Start at (seconds)', 'wp-asciiplayer' ) } type="number" min="0" step="0.1" value={ startAt } onChange={ ( value ) => setAttributes( { startAt: finiteNumber( value, 0 ) } ) } />
|
<TextControl label={ __( 'Start at (seconds)', 'wp-asciiplayer' ) } type="number" min="0" step="0.1" value={ startAt } onChange={ ( value ) => setAttributes( { startAt: finiteNumber( value, 0 ) } ) } />
|
||||||
<TextControl label={ __( 'Idle time limit (seconds)', 'wp-asciiplayer' ) } help={ __( 'Shorten long pauses. Use 0 to keep the recording’s default.', 'wp-asciiplayer' ) } type="number" min="0" step="0.1" value={ idleTimeLimit } onChange={ ( value ) => setAttributes( { idleTimeLimit: finiteNumber( value, 0 ) } ) } />
|
<TextControl label={ __( 'Idle time limit (seconds)', 'wp-asciiplayer' ) } help={ __( 'Shorten long pauses. Use 0 to keep the recording’s default.', 'wp-asciiplayer' ) } type="number" min="0" step="0.1" value={ idleTimeLimit } onChange={ ( value ) => setAttributes( { idleTimeLimit: finiteNumber( value, 0 ) } ) } />
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
@@ -87,22 +124,20 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
|
|||||||
<TextControl label={ __( 'Recording URL', 'wp-asciiplayer' ) } placeholder="https://example.com/recording.cast" value={ draftSource } onChange={ ( value ) => { setDraftSource( value ); setUrlError( false ); } } autoComplete="off" />
|
<TextControl label={ __( 'Recording URL', 'wp-asciiplayer' ) } placeholder="https://example.com/recording.cast" value={ draftSource } onChange={ ( value ) => { setDraftSource( value ); setUrlError( false ); } } autoComplete="off" />
|
||||||
<Button type="submit" variant="primary">{ __( 'Apply URL', 'wp-asciiplayer' ) }</Button>
|
<Button type="submit" variant="primary">{ __( 'Apply URL', 'wp-asciiplayer' ) }</Button>
|
||||||
</form>
|
</form>
|
||||||
<p className="asciiplayer-editor__privacy">{ __( 'Applying a URL loads the recording directly from that server, which receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.', 'wp-asciiplayer' ) }</p>
|
<p className="asciiplayer-editor__privacy">{ __( 'A valid recording URL loads its preview automatically, including when reopening this editor. That server receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.', 'wp-asciiplayer' ) }</p>
|
||||||
{ urlError && <Notice status="error" isDismissible={ false }>{ __( 'Enter an HTTP(S) recording URL or a path starting with a single /.', 'wp-asciiplayer' ) }</Notice> }
|
{ urlError && <Notice status="error" isDismissible={ false }>{ __( 'Enter an HTTP(S) recording URL or a path starting with a single /.', 'wp-asciiplayer' ) }</Notice> }
|
||||||
</div>
|
</div>
|
||||||
<figure className={ `asciiplayer-figure asciiplayer-align-${ placement }` } style={ { width: normalizeWidth( width ) } }>
|
<figure className={ `asciiplayer-figure asciiplayer-align-${ placement }` } style={ { width: normalizeWidth( width ) } }>
|
||||||
{ approvedSource && approvedSource === source ? (
|
{ showPreview ? (
|
||||||
<>
|
<>
|
||||||
<Preview source={ source } attributes={ attributes } attempt={ attempt } onRetry={ () => setAttempt( ( current ) => current + 1 ) } />
|
<Preview source={ previewSource } attributes={ attributes } attempt={ attempt } onRetry={ () => setAttempt( ( current ) => current + 1 ) } />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Placeholder icon="editor-code" label={ __( 'Asciicast Player', 'wp-asciiplayer' ) } instructions={ source ? __( 'Load the saved recording to play and adjust it here.', 'wp-asciiplayer' ) : __( 'Paste a terminal recording URL above, then apply it to see an interactive preview.', 'wp-asciiplayer' ) }>
|
<Placeholder icon="editor-code" label={ __( 'Asciicast Player', 'wp-asciiplayer' ) } instructions={ __( 'Enter a recording URL to load its preview automatically. Playback starts only when you press play.', 'wp-asciiplayer' ) } />
|
||||||
{ source && <Button variant="secondary" onClick={ () => { setApprovedSource( source ); setAttempt( ( current ) => current + 1 ); } }>{ __( 'Load preview', 'wp-asciiplayer' ) }</Button> }
|
|
||||||
</Placeholder>
|
|
||||||
) }
|
) }
|
||||||
<RichText tagName="figcaption" className={ `wp-element-caption${ ! isSelected && ! caption ? ' asciiplayer-caption-empty' : '' }` } value={ caption } allowedFormats={ [] } onChange={ ( value ) => setAttributes( { caption: value } ) } placeholder={ __( 'Add a caption…', 'wp-asciiplayer' ) } aria-label={ __( 'Recording caption', 'wp-asciiplayer' ) } />
|
<RichText tagName="figcaption" className={ `wp-element-caption${ ! isSelected && ! caption ? ' asciiplayer-caption-empty' : '' }` } value={ caption } allowedFormats={ [] } onChange={ ( value ) => setAttributes( { caption: value } ) } placeholder={ __( 'Add a caption…', 'wp-asciiplayer' ) } aria-label={ __( 'Recording caption', 'wp-asciiplayer' ) } />
|
||||||
</figure>
|
</figure>
|
||||||
{ approvedSource === source && source && <p className="asciiplayer-editor__hint">{ __( 'Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.', 'wp-asciiplayer' ) }</p> }
|
{ showPreview && <p className="asciiplayer-editor__hint">{ __( 'Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.', 'wp-asciiplayer' ) }</p> }
|
||||||
{ [ 'height', 'both' ].includes( fit ) && <p className="asciiplayer-editor__hint">{ __( 'Height-based previews use the shortcode’s fixed height when available, or a 320px editor frame. Published height still comes from your container style.', 'wp-asciiplayer' ) }</p> }
|
{ [ 'height', 'both' ].includes( fit ) && <p className="asciiplayer-editor__hint">{ __( 'Height-based previews use the shortcode’s fixed height when available, or a 320px editor frame. Published height still comes from your container style.', 'wp-asciiplayer' ) }</p> }
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -64,3 +64,10 @@
|
|||||||
* Removing it on pointerdown can move the next block's button before pointerup. */
|
* Removing it on pointerdown can move the next block's button before pointerup. */
|
||||||
.asciiplayer-editor .asciiplayer-figure > figcaption { min-height: 1.5em; }
|
.asciiplayer-editor .asciiplayer-figure > figcaption { min-height: 1.5em; }
|
||||||
.asciiplayer-editor .asciiplayer-caption-empty { visibility: hidden; }
|
.asciiplayer-editor .asciiplayer-caption-empty { visibility: hidden; }
|
||||||
|
|
||||||
|
.asciiplayer-editor__dimension-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
|
||||||
|
.asciiplayer-editor__dimension-fields input { max-width: 100%; }
|
||||||
|
|
||||||
|
.asciiplayer-terminal-popover__content { box-sizing: border-box; width: 300px; max-width: calc(100vw - 32px); padding: 16px; }
|
||||||
|
.asciiplayer-terminal-popover__content > p:first-child { margin-top: 0; }
|
||||||
|
.asciiplayer-terminal-popover__content > .components-button { margin-top: 8px; margin-right: 8px; }
|
||||||
|
|||||||
+5
-2
@@ -42,8 +42,11 @@ mapped under uploads; the package directory is mapped separately for WP-CLI.
|
|||||||
- Actual terminal output proves successful front-end parsing/playback
|
- Actual terminal output proves successful front-end parsing/playback
|
||||||
- Editor and front-end requests must not load plugin assets from jsDelivr
|
- Editor and front-end requests must not load plugin assets from jsDelivr
|
||||||
|
|
||||||
The preview intentionally requires an Apply URL / Load preview action for each
|
The preview automatically loads valid saved URLs and debounces typed changes.
|
||||||
editing session before contacting the recording server. Tests respect that gate.
|
Tests check the request count, stale-response cleanup, immediate Apply, error
|
||||||
|
retry, and no requests for empty/invalid URLs or static inserter examples.
|
||||||
|
Floating-toolbar dimension controls are checked against the collapsed sidebar,
|
||||||
|
including keyboard focus, Escape/close/reopen, and shared attribute values.
|
||||||
|
|
||||||
## CI evidence and limits
|
## CI evidence and limits
|
||||||
|
|
||||||
|
|||||||
+181
-11
@@ -53,13 +53,6 @@ async function readyPreview(block) {
|
|||||||
await expect(block.locator('.ap-wrapper')).toBeVisible();
|
await expect(block.locator('.ap-wrapper')).toBeVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadPreview(block) {
|
|
||||||
await expect(block).toBeVisible();
|
|
||||||
const load = block.getByRole('button', { name: 'Load preview', exact: true });
|
|
||||||
if (await load.count()) await load.click();
|
|
||||||
await readyPreview(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function publish(page, title) {
|
async function publish(page, title) {
|
||||||
return page.evaluate(async (postTitle) => {
|
return page.evaluate(async (postTitle) => {
|
||||||
const editor = window.wp.data.dispatch('core/editor');
|
const editor = window.wp.data.dispatch('core/editor');
|
||||||
@@ -145,12 +138,12 @@ test('real iframe preview survives edits, duplicate, delete, undo, save and relo
|
|||||||
await window.wp.data.dispatch('core/block-editor').duplicateBlocks([clientId]);
|
await window.wp.data.dispatch('core/block-editor').duplicateBlocks([clientId]);
|
||||||
return window.wp.data.select('core/block-editor').getBlocks().find((entry) => entry.name === 'lamgc/asciiplayer' && entry.clientId !== clientId).clientId;
|
return window.wp.data.select('core/block-editor').getBlocks().find((entry) => entry.name === 'lamgc/asciiplayer' && entry.clientId !== clientId).clientId;
|
||||||
}, id);
|
}, id);
|
||||||
await loadPreview(playerBlock(page, duplicateId));
|
await readyPreview(playerBlock(page, duplicateId));
|
||||||
await expect(canvas(page).locator('.asciiplayer-editor__player .ap-wrapper')).toHaveCount(2);
|
await expect(canvas(page).locator('.asciiplayer-editor__player .ap-wrapper')).toHaveCount(2);
|
||||||
await page.evaluate((clientId) => window.wp.data.dispatch('core/block-editor').removeBlocks([clientId]), duplicateId);
|
await page.evaluate((clientId) => window.wp.data.dispatch('core/block-editor').removeBlocks([clientId]), duplicateId);
|
||||||
await expect(canvas(page).locator('.asciiplayer-editor__player .ap-wrapper')).toHaveCount(1);
|
await expect(canvas(page).locator('.asciiplayer-editor__player .ap-wrapper')).toHaveCount(1);
|
||||||
await page.evaluate(() => window.wp.data.dispatch('core/editor').undo());
|
await page.evaluate(() => window.wp.data.dispatch('core/editor').undo());
|
||||||
await loadPreview(playerBlock(page, duplicateId));
|
await readyPreview(playerBlock(page, duplicateId));
|
||||||
await expect(canvas(page).locator('.asciiplayer-editor__player .ap-wrapper')).toHaveCount(2);
|
await expect(canvas(page).locator('.asciiplayer-editor__player .ap-wrapper')).toHaveCount(2);
|
||||||
await page.evaluate((clientId) => window.wp.data.dispatch('core/block-editor').removeBlocks([clientId]), duplicateId);
|
await page.evaluate((clientId) => window.wp.data.dispatch('core/block-editor').removeBlocks([clientId]), duplicateId);
|
||||||
|
|
||||||
@@ -161,7 +154,7 @@ test('real iframe preview survives edits, duplicate, delete, undo, save and relo
|
|||||||
const reloaded = await page.evaluate(() => window.wp.data.select('core/block-editor').getBlocks().find((entry) => entry.name === 'lamgc/asciiplayer'));
|
const reloaded = await page.evaluate(() => window.wp.data.select('core/block-editor').getBlocks().find((entry) => entry.name === 'lamgc/asciiplayer'));
|
||||||
expect(reloaded.name).toBe(blockName);
|
expect(reloaded.name).toBe(blockName);
|
||||||
expect(reloaded.attributes).toMatchObject({ source, speed: 1.5, theme: 'solarized-dark' });
|
expect(reloaded.attributes).toMatchObject({ source, speed: 1.5, theme: 'solarized-dark' });
|
||||||
await loadPreview(playerBlock(page, reloaded.clientId));
|
await readyPreview(playerBlock(page, reloaded.clientId));
|
||||||
|
|
||||||
await page.goto(saved.url);
|
await page.goto(saved.url);
|
||||||
const container = page.locator('.asciiplayer-container');
|
const container = page.locator('.asciiplayer-container');
|
||||||
@@ -177,7 +170,7 @@ test('a published Page plays its block at desktop and mobile widths', async ({ p
|
|||||||
await openEditor(page, 'page');
|
await openEditor(page, 'page');
|
||||||
const source = new URL(fixturePath, page.url()).href;
|
const source = new URL(fixturePath, page.url()).href;
|
||||||
const id = await insertPlayer(page, { source, controls: 'always', preload: true });
|
const id = await insertPlayer(page, { source, controls: 'always', preload: true });
|
||||||
await loadPreview(playerBlock(page, id));
|
await readyPreview(playerBlock(page, id));
|
||||||
const saved = await publish(page, 'Page playback integration');
|
const saved = await publish(page, 'Page playback integration');
|
||||||
await page.goto(saved.url);
|
await page.goto(saved.url);
|
||||||
const container = page.locator('.asciiplayer-container');
|
const container = page.locator('.asciiplayer-container');
|
||||||
@@ -259,3 +252,180 @@ test('a real cross-origin server without CORS permission shows an error and reco
|
|||||||
await new Promise((resolve) => server.close(resolve));
|
await new Promise((resolve) => server.close(resolve));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a saved Recording URL loads once without a click and never autoplays in the editor', async ({ page }) => {
|
||||||
|
await openEditor(page);
|
||||||
|
const source = new URL(`${fixturePath}?automatic=saved`, page.url()).href;
|
||||||
|
const recording = await readFile(new URL('../fixtures/hello.cast', import.meta.url));
|
||||||
|
const requests = [];
|
||||||
|
await page.route(source, async (route) => {
|
||||||
|
requests.push(route.request().url());
|
||||||
|
await route.fulfill({ contentType: 'text/plain', body: recording });
|
||||||
|
});
|
||||||
|
const id = await insertPlayer(page, { source, autoPlay: true, preload: false });
|
||||||
|
const block = playerBlock(page, id);
|
||||||
|
await readyPreview(block);
|
||||||
|
await expect(block.getByRole('button', { name: 'Load preview', exact: true })).toHaveCount(0);
|
||||||
|
await expect(block.locator('.ap-overlay-start .ap-play-button')).toBeVisible();
|
||||||
|
await expect(block.locator('.asciiplayer-editor__privacy')).toContainText(/automatic/i);
|
||||||
|
await expect(block.locator('.asciiplayer-editor__privacy')).toContainText(/server/i);
|
||||||
|
await page.waitForTimeout(750); // Catch a second fetch from a pending debounce.
|
||||||
|
expect(requests).toEqual([source]);
|
||||||
|
await expect(block.locator('.ap-overlay-start .ap-play-button')).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('rapid URL edits debounce to one recording fetch and Apply cancels its pending debounce', async ({ page }) => {
|
||||||
|
await openEditor(page);
|
||||||
|
const prefix = new URL(`${fixturePath}?automatic=`, page.url()).href;
|
||||||
|
const recording = await readFile(new URL('../fixtures/hello.cast', import.meta.url));
|
||||||
|
const requests = [];
|
||||||
|
await page.route(`${prefix}*`, async (route) => {
|
||||||
|
requests.push(route.request().url());
|
||||||
|
await route.fulfill({ contentType: 'text/plain', body: recording });
|
||||||
|
});
|
||||||
|
const id = await insertPlayer(page);
|
||||||
|
const block = playerBlock(page, id);
|
||||||
|
const input = block.getByRole('textbox', { name: 'Recording URL', exact: true });
|
||||||
|
await input.fill(`${prefix}first`);
|
||||||
|
await input.fill(`${prefix}second`);
|
||||||
|
await input.fill(`${prefix}final`);
|
||||||
|
await readyPreview(block);
|
||||||
|
await page.waitForTimeout(750);
|
||||||
|
expect(requests).toEqual([`${prefix}final`]);
|
||||||
|
await expect.poll(() => page.evaluate((clientId) =>
|
||||||
|
window.wp.data.select('core/block-editor').getBlockAttributes(clientId).source, id
|
||||||
|
)).toBe(`${prefix}final`);
|
||||||
|
await input.fill(`${prefix}applied`);
|
||||||
|
await block.getByRole('button', { name: 'Apply URL', exact: true }).click();
|
||||||
|
await expect.poll(() => requests).toEqual([`${prefix}final`, `${prefix}applied`]);
|
||||||
|
await readyPreview(block);
|
||||||
|
await page.waitForTimeout(750);
|
||||||
|
expect(requests).toEqual([`${prefix}final`, `${prefix}applied`]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('replacing a pending recording ignores its stale response', async ({ page }) => {
|
||||||
|
await openEditor(page);
|
||||||
|
const source = new URL(`${fixturePath}?automatic=stale`, page.url()).href;
|
||||||
|
const latest = new URL(`${fixturePath}?automatic=latest`, page.url()).href;
|
||||||
|
const recording = await readFile(new URL('../fixtures/hello.cast', import.meta.url), 'utf8');
|
||||||
|
let release;
|
||||||
|
const pending = new Promise((resolve) => { release = resolve; });
|
||||||
|
let oldRequested = false;
|
||||||
|
let oldResponseSettled = false;
|
||||||
|
await page.route(source, async (route) => {
|
||||||
|
oldRequested = true;
|
||||||
|
await pending;
|
||||||
|
// Aborting a replaced player may cancel this intercepted request. Both
|
||||||
|
// cancellation and safely ignoring a late response are valid outcomes.
|
||||||
|
await route.fulfill({ contentType: 'text/plain', body: recording.replace('"width":64', '"width":120') }).catch(() => {});
|
||||||
|
oldResponseSettled = true;
|
||||||
|
});
|
||||||
|
await page.route(latest, (route) => route.fulfill({ contentType: 'text/plain', body: recording }));
|
||||||
|
try {
|
||||||
|
const id = await insertPlayer(page, { source });
|
||||||
|
const block = playerBlock(page, id);
|
||||||
|
await expect.poll(() => oldRequested).toBe(true);
|
||||||
|
await block.getByRole('textbox', { name: 'Recording URL', exact: true }).fill(latest);
|
||||||
|
await expect.poll(() => page.evaluate((clientId) =>
|
||||||
|
window.wp.data.select('core/block-editor').getBlockAttributes(clientId).source, id
|
||||||
|
)).toBe(latest);
|
||||||
|
await readyPreview(block);
|
||||||
|
release();
|
||||||
|
await expect.poll(() => oldResponseSettled).toBe(true);
|
||||||
|
await page.waitForTimeout(750);
|
||||||
|
await readyPreview(block);
|
||||||
|
await expect.poll(() => block.locator('.ap-term').evaluate((terminal) =>
|
||||||
|
Number(terminal.style.getPropertyValue('--term-cols'))
|
||||||
|
)).toBe(64);
|
||||||
|
await expect(block.getByRole('textbox', { name: 'Recording URL', exact: true })).toHaveValue(latest);
|
||||||
|
} finally {
|
||||||
|
release();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('automatic preview errors retry the unchanged URL through Retry preview and Apply URL', async ({ page }) => {
|
||||||
|
await openEditor(page);
|
||||||
|
const source = new URL(`${fixturePath}?automatic=retry`, page.url()).href;
|
||||||
|
const recording = await readFile(new URL('../fixtures/hello.cast', import.meta.url));
|
||||||
|
let requests = 0;
|
||||||
|
await page.route(source, async (route) => {
|
||||||
|
requests += 1;
|
||||||
|
await route.fulfill(requests < 3
|
||||||
|
? { status: 503, contentType: 'text/plain', body: 'Temporarily unavailable' }
|
||||||
|
: { contentType: 'text/plain', body: recording });
|
||||||
|
});
|
||||||
|
const id = await insertPlayer(page, { source });
|
||||||
|
const block = playerBlock(page, id);
|
||||||
|
const preview = block.locator('.asciiplayer-editor__preview');
|
||||||
|
await expect(preview).toHaveAttribute('data-preview-status', 'error');
|
||||||
|
expect(requests).toBe(1);
|
||||||
|
await block.getByRole('button', { name: 'Retry preview', exact: true }).click();
|
||||||
|
await expect.poll(() => requests).toBe(2);
|
||||||
|
await expect(preview).toHaveAttribute('data-preview-status', 'error');
|
||||||
|
await block.getByRole('button', { name: 'Apply URL', exact: true }).click();
|
||||||
|
await readyPreview(block);
|
||||||
|
await page.waitForTimeout(750);
|
||||||
|
expect(requests).toBe(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('empty and invalid sources never create a preview or fetch a recording', async ({ page }) => {
|
||||||
|
await openEditor(page);
|
||||||
|
const requests = [];
|
||||||
|
page.on('request', (request) => {
|
||||||
|
if (/\.cast(?:[?#]|$)|asciinema\.org|jsdelivr\.net/.test(request.url())) requests.push(request.url());
|
||||||
|
});
|
||||||
|
const emptyId = await insertPlayer(page);
|
||||||
|
const empty = playerBlock(page, emptyId);
|
||||||
|
const invalidId = await insertPlayer(page, { source: 'javascript:alert(1)' });
|
||||||
|
const invalid = playerBlock(page, invalidId);
|
||||||
|
await expect(empty.getByRole('textbox', { name: 'Recording URL', exact: true })).toHaveValue('');
|
||||||
|
await expect(invalid.getByRole('textbox', { name: 'Recording URL', exact: true })).toHaveValue('javascript:alert(1)');
|
||||||
|
await page.waitForTimeout(750);
|
||||||
|
await expect(empty.locator('.asciiplayer-editor__preview')).toHaveCount(0);
|
||||||
|
await expect(invalid.locator('.asciiplayer-editor__preview')).toHaveCount(0);
|
||||||
|
const input = empty.getByRole('textbox', { name: 'Recording URL', exact: true });
|
||||||
|
await input.fill(new URL(fixturePath, page.url()).href);
|
||||||
|
await input.fill('');
|
||||||
|
await page.waitForTimeout(750);
|
||||||
|
await expect(empty.locator('.asciiplayer-editor__preview')).toHaveCount(0);
|
||||||
|
await input.fill('https://');
|
||||||
|
await page.waitForTimeout(750);
|
||||||
|
await expect(empty.locator('.asciiplayer-editor__preview')).toHaveCount(0);
|
||||||
|
expect(requests).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('external source changes and undo clear an invalid draft error and restore the valid preview', async ({ page }) => {
|
||||||
|
await openEditor(page);
|
||||||
|
const original = new URL(`${fixturePath}?automatic=undo-original`, page.url()).href;
|
||||||
|
const replacement = new URL(`${fixturePath}?automatic=undo-replacement`, page.url()).href;
|
||||||
|
const id = await insertPlayer(page, { source: original });
|
||||||
|
const block = playerBlock(page, id);
|
||||||
|
const input = block.getByRole('textbox', { name: 'Recording URL', exact: true });
|
||||||
|
const validation = block.locator('.asciiplayer-editor__source .components-notice');
|
||||||
|
await readyPreview(block);
|
||||||
|
// Save a baseline so Undo below targets the external source replacement,
|
||||||
|
// rather than an insertion or another edit batched into the same history.
|
||||||
|
await publish(page, 'Automatic preview source synchronization regression');
|
||||||
|
await input.fill('https://');
|
||||||
|
await expect(validation).toContainText('Enter an HTTP(S) recording URL');
|
||||||
|
await expect(block.locator('.asciiplayer-editor__preview')).toHaveCount(0);
|
||||||
|
await page.evaluate(({ clientId, source }) =>
|
||||||
|
window.wp.data.dispatch('core/block-editor').updateBlockAttributes(clientId, { source }),
|
||||||
|
{ clientId: id, source: replacement });
|
||||||
|
await expect(input).toHaveValue(replacement);
|
||||||
|
await readyPreview(block);
|
||||||
|
await expect(validation).toHaveCount(0);
|
||||||
|
// An invalid local draft does not change the saved source or undo history.
|
||||||
|
await input.fill('javascript:alert(1)');
|
||||||
|
await expect(validation).toContainText('Enter an HTTP(S) recording URL');
|
||||||
|
await expect(block.locator('.asciiplayer-editor__preview')).toHaveCount(0);
|
||||||
|
await page.evaluate(() => window.wp.data.dispatch('core/editor').undo());
|
||||||
|
await expect(input).toHaveValue(original);
|
||||||
|
await readyPreview(block);
|
||||||
|
await expect(validation).toHaveCount(0);
|
||||||
|
await page.waitForTimeout(750); // A canceled invalid-draft timer cannot reappear.
|
||||||
|
await expect(validation).toHaveCount(0);
|
||||||
|
await expect.poll(() => page.evaluate((clientId) =>
|
||||||
|
window.wp.data.select('core/block-editor').getBlockAttributes(clientId).source, id
|
||||||
|
)).toBe(original);
|
||||||
|
});
|
||||||
|
|||||||
+75
-13
@@ -36,8 +36,7 @@ async function attributes(page, id) {
|
|||||||
return page.evaluate((clientId) => window.wp.data.select('core/block-editor').getBlockAttributes(clientId), id);
|
return page.evaluate((clientId) => window.wp.data.select('core/block-editor').getBlockAttributes(clientId), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadPreview(block) {
|
async function readyPreview(block) {
|
||||||
await block.getByRole('button', { name: 'Load preview', exact: true }).click();
|
|
||||||
await expect(block.locator('.asciiplayer-editor__preview')).toHaveAttribute('data-preview-status', 'ready');
|
await expect(block.locator('.asciiplayer-editor__preview')).toHaveAttribute('data-preview-status', 'ready');
|
||||||
await expect(block.locator('.ap-wrapper')).toHaveCount(1);
|
await expect(block.locator('.ap-wrapper')).toHaveCount(1);
|
||||||
}
|
}
|
||||||
@@ -114,7 +113,7 @@ test('display width, alignment and caption survive editor save/reload without ch
|
|||||||
await openEditor(page);
|
await openEditor(page);
|
||||||
const source = new URL(fixturePath, page.url()).href;
|
const source = new URL(fixturePath, page.url()).href;
|
||||||
const { id, block } = await insertPlayer(page, { source, controls: 'always' });
|
const { id, block } = await insertPlayer(page, { source, controls: 'always' });
|
||||||
await loadPreview(block);
|
await readyPreview(block);
|
||||||
await expectGrid(block, 64, 12);
|
await expectGrid(block, 64, 12);
|
||||||
expect((await attributes(page, id)).cols).toBeUndefined();
|
expect((await attributes(page, id)).cols).toBeUndefined();
|
||||||
expect((await attributes(page, id)).rows).toBeUndefined();
|
expect((await attributes(page, id)).rows).toBeUndefined();
|
||||||
@@ -155,7 +154,7 @@ test('display width, alignment and caption survive editor save/reload without ch
|
|||||||
expect(reloaded.attributes.cols).toBeUndefined();
|
expect(reloaded.attributes.cols).toBeUndefined();
|
||||||
expect(reloaded.attributes.rows).toBeUndefined();
|
expect(reloaded.attributes.rows).toBeUndefined();
|
||||||
const reloadedBlock = page.frameLocator('iframe[name="editor-canvas"]').locator(`[data-block="${reloaded.clientId}"]`);
|
const reloadedBlock = page.frameLocator('iframe[name="editor-canvas"]').locator(`[data-block="${reloaded.clientId}"]`);
|
||||||
await loadPreview(reloadedBlock);
|
await readyPreview(reloadedBlock);
|
||||||
await expectGrid(reloadedBlock, 64, 12);
|
await expectGrid(reloadedBlock, 64, 12);
|
||||||
await expectAlignment(reloadedBlock.locator('.asciiplayer-figure'), 'right');
|
await expectAlignment(reloadedBlock.locator('.asciiplayer-figure'), 'right');
|
||||||
await page.setViewportSize({ width: 390, height: 844 });
|
await page.setViewportSize({ width: 390, height: 844 });
|
||||||
@@ -184,21 +183,59 @@ test('display width, alignment and caption survive editor save/reload without ch
|
|||||||
await screenshot(page, testInfo, 'layout-frontend-mobile');
|
await screenshot(page, testInfo, 'layout-frontend-mobile');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('optional columns and rows override the grid and clearing or resetting restores recording metadata', async ({ page }) => {
|
test('toolbar terminal dimensions are discoverable, preserve focus and synchronize with the collapsed sidebar', async ({ page }, testInfo) => {
|
||||||
await openEditor(page);
|
await openEditor(page);
|
||||||
const source = new URL(fixturePath, page.url()).href;
|
const source = new URL(fixturePath, page.url()).href;
|
||||||
const { id, block } = await insertPlayer(page, { source });
|
const { id, block } = await insertPlayer(page, { source });
|
||||||
await loadPreview(block);
|
await readyPreview(block);
|
||||||
const columns = page.getByRole('spinbutton', { name: 'Columns', exact: true });
|
await expect(block.getByRole('spinbutton', { name: 'Columns', exact: true })).toHaveCount(0);
|
||||||
const rows = page.getByRole('spinbutton', { name: 'Rows', exact: true });
|
await expect(block.getByRole('spinbutton', { name: 'Rows', exact: true })).toHaveCount(0);
|
||||||
await openInspectorPanel(page, 'Terminal size', columns);
|
await page.evaluate(() => window.wp.data.dispatch('core/edit-post').closeGeneralSidebar());
|
||||||
|
// Core hides contextual tools while typing; mirror its own test utility.
|
||||||
|
await page.mouse.move(50, 50);
|
||||||
|
await page.mouse.move(75, 75);
|
||||||
|
await page.mouse.move(100, 100);
|
||||||
|
const toolbar = page.getByRole('toolbar', { name: 'Block tools', exact: true });
|
||||||
|
const toggle = toolbar.getByRole('button', { name: 'Terminal size', exact: true });
|
||||||
|
await expect(toggle).toBeVisible();
|
||||||
|
await block.scrollIntoViewIfNeeded();
|
||||||
|
await page.waitForTimeout(300); // Let the sidebar-close layout transition settle.
|
||||||
|
const before = await block.boundingBox();
|
||||||
|
await toggle.click();
|
||||||
|
const popover = page.getByRole('dialog', { name: 'Terminal size', exact: true });
|
||||||
|
const columns = popover.getByRole('spinbutton', { name: 'Columns', exact: true });
|
||||||
|
const rows = popover.getByRole('spinbutton', { name: 'Rows', exact: true });
|
||||||
|
await expect(popover).toBeVisible();
|
||||||
|
await expect(columns).toBeVisible();
|
||||||
|
await expect(rows).toBeVisible();
|
||||||
|
await expect(columns).toBeFocused();
|
||||||
await expect(columns).toHaveValue('');
|
await expect(columns).toHaveValue('');
|
||||||
await expect(rows).toHaveValue('');
|
await expect(rows).toHaveValue('');
|
||||||
|
const after = await block.boundingBox();
|
||||||
|
expect(Math.abs(after.width - before.width)).toBeLessThan(2);
|
||||||
|
expect(Math.abs(after.height - before.height)).toBeLessThan(2);
|
||||||
|
await screenshot(page, testInfo, 'terminal-size-toolbar-popover');
|
||||||
|
// Invalid overrides are cleared rather than changing the recording grid.
|
||||||
|
await columns.fill('0');
|
||||||
|
await columns.press('Tab');
|
||||||
|
await rows.fill('1001');
|
||||||
|
await rows.press('Tab');
|
||||||
|
await expect(columns).toHaveValue('');
|
||||||
|
await expect(rows).toHaveValue('');
|
||||||
|
expect((await attributes(page, id)).cols).toBeUndefined();
|
||||||
|
expect((await attributes(page, id)).rows).toBeUndefined();
|
||||||
|
await expectGrid(block, 64, 12);
|
||||||
await columns.fill('88');
|
await columns.fill('88');
|
||||||
await columns.press('Tab');
|
await columns.press('Tab');
|
||||||
await rows.fill('16');
|
await rows.fill('16');
|
||||||
await rows.press('Tab');
|
await rows.press('Tab');
|
||||||
await expectGrid(block, 88, 16);
|
await expectGrid(block, 88, 16);
|
||||||
|
await rows.press('Escape');
|
||||||
|
await expect(popover).toBeHidden();
|
||||||
|
await expect(toggle).toBeFocused();
|
||||||
|
await toggle.click();
|
||||||
|
await expect(columns).toHaveValue('88');
|
||||||
|
await expect(rows).toHaveValue('16');
|
||||||
await columns.fill('');
|
await columns.fill('');
|
||||||
await columns.press('Tab');
|
await columns.press('Tab');
|
||||||
await expectGrid(block, 64, 16);
|
await expectGrid(block, 64, 16);
|
||||||
@@ -206,12 +243,35 @@ test('optional columns and rows override the grid and clearing or resetting rest
|
|||||||
await columns.fill('88');
|
await columns.fill('88');
|
||||||
await columns.press('Tab');
|
await columns.press('Tab');
|
||||||
await expectGrid(block, 88, 16);
|
await expectGrid(block, 88, 16);
|
||||||
await page.getByRole('button', { name: 'Use recording size', exact: true }).click();
|
await popover.getByRole('button', { name: 'Use recording size', exact: true }).click();
|
||||||
await expectGrid(block, 64, 12);
|
await expectGrid(block, 64, 12);
|
||||||
await expect(columns).toHaveValue('');
|
await expect(columns).toHaveValue('');
|
||||||
await expect(rows).toHaveValue('');
|
await expect(rows).toHaveValue('');
|
||||||
|
await columns.fill('88');
|
||||||
|
await rows.fill('16');
|
||||||
|
await rows.press('Tab');
|
||||||
|
await expectGrid(block, 88, 16);
|
||||||
|
await popover.getByRole('button', { name: 'Close', exact: true }).click();
|
||||||
|
await expect(popover).toBeHidden();
|
||||||
|
await page.evaluate(() => window.wp.data.dispatch('core/edit-post').openGeneralSidebar('edit-post/block'));
|
||||||
|
const panelToggle = page.locator('.components-panel__body-toggle').filter({ hasText: /^Terminal size$/ });
|
||||||
|
await expect(panelToggle).toHaveAttribute('aria-expanded', 'false');
|
||||||
|
await panelToggle.click();
|
||||||
|
const sidebarColumns = page.getByRole('spinbutton', { name: 'Columns', exact: true });
|
||||||
|
const sidebarRows = page.getByRole('spinbutton', { name: 'Rows', exact: true });
|
||||||
|
await expect(sidebarColumns).toHaveValue('88');
|
||||||
|
await expect(sidebarRows).toHaveValue('16');
|
||||||
|
await sidebarRows.fill('');
|
||||||
|
await sidebarRows.press('Tab');
|
||||||
|
await expectGrid(block, 88, 12);
|
||||||
|
await page.getByRole('button', { name: 'Use recording size', exact: true }).click();
|
||||||
|
await expectGrid(block, 64, 12);
|
||||||
expect((await attributes(page, id)).cols).toBeUndefined();
|
expect((await attributes(page, id)).cols).toBeUndefined();
|
||||||
expect((await attributes(page, id)).rows).toBeUndefined();
|
expect((await attributes(page, id)).rows).toBeUndefined();
|
||||||
|
await toggle.click();
|
||||||
|
await expect(columns).toHaveValue('');
|
||||||
|
await expect(rows).toHaveValue('');
|
||||||
|
await popover.getByRole('button', { name: 'Close', exact: true }).click();
|
||||||
const saved = await publish(page, 'Reset terminal dimensions regression');
|
const saved = await publish(page, 'Reset terminal dimensions regression');
|
||||||
await page.goto(saved.url);
|
await page.goto(saved.url);
|
||||||
const frontend = page.locator('.asciiplayer-container');
|
const frontend = page.locator('.asciiplayer-container');
|
||||||
@@ -232,7 +292,7 @@ test('recorded resize events remain authoritative except on explicitly overridde
|
|||||||
];
|
];
|
||||||
for (const entry of cases) {
|
for (const entry of cases) {
|
||||||
const { block } = await insertPlayer(page, { source, startAt: 2, ...entry.overrides });
|
const { block } = await insertPlayer(page, { source, startAt: 2, ...entry.overrides });
|
||||||
await loadPreview(block);
|
await readyPreview(block);
|
||||||
await expectGrid(block, entry.overrides.cols ?? 64, entry.overrides.rows ?? 12);
|
await expectGrid(block, entry.overrides.cols ?? 64, entry.overrides.rows ?? 12);
|
||||||
await block.locator('.ap-overlay-start .ap-play-button').click();
|
await block.locator('.ap-overlay-start .ap-play-button').click();
|
||||||
await expectGrid(block, entry.cols, entry.rows);
|
await expectGrid(block, entry.cols, entry.rows);
|
||||||
@@ -373,10 +433,12 @@ test('the inserter example is a local static preview and makes no recording requ
|
|||||||
page.on('request', (request) => {
|
page.on('request', (request) => {
|
||||||
if (/\.cast(?:[?#]|$)|asciinema\.org|jsdelivr\.net/.test(request.url())) recordingRequests.push(request.url());
|
if (/\.cast(?:[?#]|$)|asciinema\.org|jsdelivr\.net/.test(request.url())) recordingRequests.push(request.url());
|
||||||
});
|
});
|
||||||
const { block } = await insertPlayer(page, example.attributes);
|
// A saved URL must never turn an inserter example into a network preview.
|
||||||
|
const { block } = await insertPlayer(page, { ...example.attributes, source: new URL(fixturePath, page.url()).href });
|
||||||
await expect(block.locator('.asciiplayer-example')).toContainText('Hello, terminal!');
|
await expect(block.locator('.asciiplayer-example')).toContainText('Hello, terminal!');
|
||||||
await expect(block.getByRole('textbox', { name: 'Recording URL', exact: true })).toHaveCount(0);
|
await expect(block.getByRole('textbox', { name: 'Recording URL', exact: true })).toHaveCount(0);
|
||||||
await expect(block.locator('.ap-wrapper')).toHaveCount(0);
|
await expect(block.locator('.ap-wrapper')).toHaveCount(0);
|
||||||
|
await page.waitForTimeout(750); // Exceed the automatic URL debounce window.
|
||||||
await screenshot(page, testInfo, 'static-inserter-example');
|
await screenshot(page, testInfo, 'static-inserter-example');
|
||||||
expect(recordingRequests).toEqual([]);
|
expect(recordingRequests).toEqual([]);
|
||||||
});
|
});
|
||||||
@@ -412,7 +474,7 @@ test('outer editor blocks respect WordPress content gutters and core wide/full b
|
|||||||
return entries;
|
return entries;
|
||||||
}, { name: blockName, sourceUrl: source });
|
}, { name: blockName, sourceUrl: source });
|
||||||
const canvas = page.frameLocator('iframe[name="editor-canvas"]');
|
const canvas = page.frameLocator('iframe[name="editor-canvas"]');
|
||||||
for (const entry of cases) await loadPreview(canvas.locator(`[data-block="${entry.playerId}"]`));
|
for (const entry of cases) await readyPreview(canvas.locator(`[data-block="${entry.playerId}"]`));
|
||||||
for (const viewport of [{ width: 1280, height: 900 }, { width: 390, height: 844 }]) {
|
for (const viewport of [{ width: 1280, height: 900 }, { width: 390, height: 844 }]) {
|
||||||
await page.setViewportSize(viewport);
|
await page.setViewportSize(viewport);
|
||||||
for (const entry of cases) {
|
for (const entry of cases) {
|
||||||
|
|||||||
+2
-2
@@ -60,8 +60,8 @@ try {
|
|||||||
same( array( 'lamgc-asciiplayer-player-style' ), $GLOBALS['ap_test']['styles']['lamgc-asciiplayer-style']['deps'], 'Frontend style depends on player stylesheet.' );
|
same( array( 'lamgc-asciiplayer-player-style' ), $GLOBALS['ap_test']['styles']['lamgc-asciiplayer-style']['deps'], 'Frontend style depends on player stylesheet.' );
|
||||||
contains( 'window.wpAsciiplayerSettings = ', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Editor iframe receives trusted runtime URLs.' );
|
contains( 'window.wpAsciiplayerSettings = ', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Editor iframe receives trusted runtime URLs.' );
|
||||||
same( 'before', $GLOBALS['ap_test']['inline_scripts'][0]['position'], 'Settings are available before editor boot.' );
|
same( 'before', $GLOBALS['ap_test']['inline_scripts'][0]['position'], 'Settings are available before editor boot.' );
|
||||||
contains( 'player.js?ver=1.2.0', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge JavaScript cache-buster matches registered asset version.' );
|
contains( 'player.js?ver=1.2.1', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge JavaScript cache-buster matches registered asset version.' );
|
||||||
contains( 'player.css?ver=1.2.0', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge CSS cache-buster matches registered asset version.' );
|
contains( 'player.css?ver=1.2.1', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge CSS cache-buster matches registered asset version.' );
|
||||||
|
|
||||||
// Source validation covers script, HTML, credential and relative-URL attacks.
|
// Source validation covers script, HTML, credential and relative-URL attacks.
|
||||||
foreach ( array( '', 'javascript:alert(1)', 'data:text/html,test', 'file:///tmp/a.cast', '//evil.test/a.cast', '/\\evil.test/a.cast', "https://example.test/a\n.cast", 'https://x.test/" onmouseover="alert(1)', 'https://user:[email protected]/a.cast', 'https:///a.cast', 'a.cast', array( 'bad' ) ) as $source ) {
|
foreach ( array( '', 'javascript:alert(1)', 'data:text/html,test', 'file:///tmp/a.cast', '//evil.test/a.cast', '/\\evil.test/a.cast', "https://example.test/a\n.cast", 'https://x.test/" onmouseover="alert(1)', 'https://user:[email protected]/a.cast', 'https:///a.cast', 'a.cast', array( 'bad' ) ) as $source ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user