Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong context.location in ampcontext #10631

Merged
merged 2 commits into from Jul 25, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion 3p/ampcontext.js
Expand Up @@ -21,6 +21,7 @@ import {nextTick} from './3p';
import {tryParseJson} from '../src/json';
import {isObject} from '../src/types';
import {AmpEvents} from '../src/amp-events';
import {parseUrl} from '../src/url';

export class AbstractAmpContext {

Expand Down Expand Up @@ -256,7 +257,7 @@ export class AbstractAmpContext {
this.hidden = context.hidden;
this.initialLayoutRect = context.initialLayoutRect;
this.initialIntersection = context.initialIntersection;
this.location = context.location;
this.location = parseUrl(context.location.href);
this.mode = context.mode;
this.pageViewId = context.pageViewId;
this.referrer = context.referrer;
Expand Down
12 changes: 11 additions & 1 deletion test/integration/test-amp-ad-3p.js
Expand Up @@ -86,7 +86,17 @@ function createIframeWithApis(fixture) {
expect(context.initialIntersection.rootBounds).to.be.defined;
expect(context.isMaster).to.be.defined;
expect(context.computeInMasterFrame).to.be.defined;
expect(context.location).to.be.defined;
expect(context.location).to.deep.equal({
hash: '',
host: 'localhost:9876',
hostname: 'localhost',
href: 'http://localhost:9876/context.html',
origin: 'http://localhost:9876',
pathname: '/context.html',
port: '9876',
protocol: 'http:',
search: '',
});
expect(context.sourceUrl).to.be.a('string');
}).then(() => {
// test iframe will send out render-start to amp-ad
Expand Down