Skip to content

Commit

Permalink
append a base element to force the baseURI of the FakeWindow (#40218)
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinmombay authored Jan 8, 2025
1 parent ed53619 commit 5129866
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@ describes.fakeWin(
expect(resolver.getAnchorDomain_(anchor)).to.equal('test.com');
});

// TODO(#40214): fix flaky test.
it.skip('removes // protocol', () => {
it('removes // protocol', () => {
const anchor = helpers.createAnchor('//test.com/');
expect(resolver.getAnchorDomain_(anchor)).to.equal('test.com');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ describes.endtoend(
await expect(player);
});

// TODO(#40214): fix flaky test.
it.skip('loads and displays first story on page load when player is visible in viewport', async () => {
it('loads and displays first story on page load when player is visible in viewport', async () => {
const shadowHost = await controller.findElement(
'div.i-amphtml-story-player-shadow-root-intermediary'
);
Expand Down
3 changes: 1 addition & 2 deletions extensions/amp-video/0.1/test/test-flexible-bitrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ describes.fakeWin('amp-video flexible-bitrate', {}, (env) => {
expect(currentBitrates(v0)[0]).to.equal(1000);
});

// TODO(#40214): fix flaky test.
it.skip('should observe lower bandwidth on next sort', () => {
it('should observe lower bandwidth on next sort', () => {
const m = getManager('4g');
const v0 = getVideo([4000, 1000, 3000, 2000]);
v0.id = 'v0';
Expand Down
8 changes: 8 additions & 0 deletions testing/fake-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ export class FakeWindow {
// Document.
/** @const {!HTMLDocument} */
this.document = self.document.implementation.createHTMLDocument('');
// NOTE: There was a change between chrome 119 and 120 where the above
// self.document.implementation.createHTMLDocument no longer inherits
// the baseURI of self.document. We explicitly set and force it thru
// a `<base>` element.
const base = this.document.createElement('base');
base.href = self.document.baseURI;
this.document.head.appendChild(base);

Object.defineProperty(this.document, 'defaultView', {
get: () => this,
});
Expand Down

0 comments on commit 5129866

Please sign in to comment.