From a5551d10a806fda9eabed1cad705ea01ecab0170 Mon Sep 17 00:00:00 2001 From: Danijel Ristic Date: Tue, 17 Sep 2024 12:45:25 +0200 Subject: [PATCH 1/3] Add TargetVideo Alias --- examples/brid-player.amp.html | 16 ++++++++++++++++ .../amp-brid-player/0.1/amp-brid-player.js | 2 ++ .../0.1/test/test-amp-brid-player.js | 19 +++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/examples/brid-player.amp.html b/examples/brid-player.amp.html index 05416db07955..fee970ca9d2f 100644 --- a/examples/brid-player.amp.html +++ b/examples/brid-player.amp.html @@ -34,6 +34,22 @@

Actions

+

Target Video Alias

+ + +

Actions

+ + + + + +

Autoplay

{ AMP.registerElement(TAG, AmpBridPlayer); + AMP.registerElement(ALIAS, AmpBridPlayer); }); diff --git a/extensions/amp-brid-player/0.1/test/test-amp-brid-player.js b/extensions/amp-brid-player/0.1/test/test-amp-brid-player.js index 2fb9941880ea..a831340ff249 100644 --- a/extensions/amp-brid-player/0.1/test/test-amp-brid-player.js +++ b/extensions/amp-brid-player/0.1/test/test-amp-brid-player.js @@ -22,8 +22,8 @@ describes.realWin( timer = Services.timerFor(win); }); - function getBridPlayer(attributes, opt_responsive, config) { - const bc = doc.createElement('amp-brid-player'); + function getBridPlayer(attributes, opt_responsive, config, alias = false) { + const bc = alias ? doc.createElement('amp-target-video-player') : doc.createElement('amp-brid-player'); for (const key in attributes) { bc.setAttribute(key, attributes[key]); @@ -83,6 +83,21 @@ describes.realWin( }); }); + it('renders alias', () => { + return getBridPlayer({ + 'data-partner': '264', + 'data-player': '4144', + 'data-video': '13663', + }, null, null, true).then((bc) => { + const iframe = bc.querySelector('iframe'); + expect(iframe).to.not.be.null; + expect(iframe.tagName).to.equal('IFRAME'); + expect(iframe.src).to.equal( + 'https://services.brid.tv/services/iframe/video/13663/264/4144/0/1/?amp=1' + ); + }); + }); + it('renders responsively', () => { return getBridPlayer( { From aa46a48a8e560ee7d7af2d2a3007c39d1477b2a4 Mon Sep 17 00:00:00 2001 From: Danijel Ristic Date: Wed, 18 Sep 2024 10:29:05 +0200 Subject: [PATCH 2/3] Lint, address PR comments --- .../amp-brid-player/0.1/amp-brid-player.js | 7 +++---- .../0.1/test/test-amp-brid-player.js | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/extensions/amp-brid-player/0.1/amp-brid-player.js b/extensions/amp-brid-player/0.1/amp-brid-player.js index 4ff025f105d2..c6074b1e0049 100644 --- a/extensions/amp-brid-player/0.1/amp-brid-player.js +++ b/extensions/amp-brid-player/0.1/amp-brid-player.js @@ -35,7 +35,6 @@ import {assertAbsoluteHttpOrHttpsUrl} from '../../../src/url'; import {VideoEvents_Enum} from '../../../src/video-interface'; const TAG = 'amp-brid-player'; -const ALIAS = 'amp-target-video-player'; /** * @implements {../../../src/video-interface.VideoInterface} @@ -494,7 +493,7 @@ class AmpBridPlayer extends AMP.BaseElement { } } -AMP.extension(TAG, '0.1', (AMP) => { - AMP.registerElement(TAG, AmpBridPlayer); - AMP.registerElement(ALIAS, AmpBridPlayer); +AMP.extension('amp-brid-player', '0.1', (AMP) => { + AMP.registerElement('amp-brid-player', AmpBridPlayer); + AMP.registerElement('amp-target-video-player', AmpBridPlayer); }); diff --git a/extensions/amp-brid-player/0.1/test/test-amp-brid-player.js b/extensions/amp-brid-player/0.1/test/test-amp-brid-player.js index a831340ff249..66cfe1f3f8bc 100644 --- a/extensions/amp-brid-player/0.1/test/test-amp-brid-player.js +++ b/extensions/amp-brid-player/0.1/test/test-amp-brid-player.js @@ -23,7 +23,9 @@ describes.realWin( }); function getBridPlayer(attributes, opt_responsive, config, alias = false) { - const bc = alias ? doc.createElement('amp-target-video-player') : doc.createElement('amp-brid-player'); + const bc = alias + ? doc.createElement('amp-target-video-player') + : doc.createElement('amp-brid-player'); for (const key in attributes) { bc.setAttribute(key, attributes[key]); @@ -84,11 +86,16 @@ describes.realWin( }); it('renders alias', () => { - return getBridPlayer({ - 'data-partner': '264', - 'data-player': '4144', - 'data-video': '13663', - }, null, null, true).then((bc) => { + return getBridPlayer( + { + 'data-partner': '264', + 'data-player': '4144', + 'data-video': '13663', + }, + null, + null, + true + ).then((bc) => { const iframe = bc.querySelector('iframe'); expect(iframe).to.not.be.null; expect(iframe.tagName).to.equal('IFRAME'); From f341ab1dffe6923ba3ca46e73dd34c24ca054130 Mon Sep 17 00:00:00 2001 From: Danijel Ristic Date: Wed, 18 Sep 2024 12:30:22 +0200 Subject: [PATCH 3/3] Update validator, revert examples --- examples/brid-player.amp.html | 16 ------ .../validator-amp-brid-player.protoascii | 54 +++++++++++++++++++ 2 files changed, 54 insertions(+), 16 deletions(-) diff --git a/examples/brid-player.amp.html b/examples/brid-player.amp.html index fee970ca9d2f..05416db07955 100644 --- a/examples/brid-player.amp.html +++ b/examples/brid-player.amp.html @@ -34,22 +34,6 @@

Actions

-

Target Video Alias

- - -

Actions

- - - - - -

Autoplay

supported_layouts: RESPONSIVE } } +tags: { # + html_format: AMP + tag_name: "AMP-TARGET-VIDEO-PLAYER" + requires_extension: "amp-brid-player" + attrs: { name: "autoplay" } + attrs: { + name: "data-dynamic" + value_regex: "[a-z]+" + } + attrs: { + name: "data-outstream" + mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']" + value_regex: "[0-9]+" + } + attrs: { + name: "data-partner" + mandatory: true + value_regex: "[0-9]+" + } + attrs: { + name: "data-player" + mandatory: true + value_regex: "[0-9]+" + } + attrs: { + name: "data-playlist" + mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']" + value_regex: ".+" + } + attrs: { + name: "data-video" + mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']" + value_regex: "[0-9]+" + } + attrs: { + name: "data-carousel" + mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']" + value_regex: "[0-9]+" + } + attrs: { + name: "dock" + requires_extension: "amp-video-docking" + } + attr_lists: "extended-amp-global" + spec_url: "https://amp.dev/documentation/components/amp-brid-player/" + amp_layout: { + supported_layouts: FILL + supported_layouts: FIXED + supported_layouts: FIXED_HEIGHT + supported_layouts: FLEX_ITEM + supported_layouts: NODISPLAY + supported_layouts: RESPONSIVE + } +}