Skip to content

Commit

Permalink
Part 1: Stop using |global|, and fix a typo ('param' should have been…
Browse files Browse the repository at this point in the history
… 'args') in mock-idp.js

Differential Revision: https://phabricator.services.mozilla.com/D24786

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1534692
gecko-commit: 6adc2a2a4988785c5d69a51f7746cef0bb46b57b
gecko-integration-branch: central
gecko-reviewers: jib
  • Loading branch information
docfaraday authored and jgraham committed Apr 25, 2019
1 parent 8255889 commit 9e3abe2
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions .well-known/idp-proxy/mock-idp.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ function parseQueryString(urlStr) {
};
*/

// In RTCIdentityProviderGlobalScope, global is self
const global = self;
const query = parseQueryString(global.location);
const query = parseQueryString(location);

// Generate a naive identity assertion. The result assertion
// is a JSON string that report the various parameters
Expand All @@ -73,8 +71,8 @@ function generateAssertion(contents, origin, options) {
};

const env = {
origin: global.origin,
location: global.location
origin,
location
};

const assertion = {
Expand All @@ -84,11 +82,6 @@ function generateAssertion(contents, origin, options) {
query
};

const idp = {
domain: global.location.host,
protocol: 'mock-idp.js'
};

const assertionStr = JSON.stringify(assertion);

const { generatorAction } = query;
Expand All @@ -100,7 +93,7 @@ function generateAssertion(contents, origin, options) {

} else if(generatorAction === 'require-login') {
const err = new RTCError('idp-need-login');
err.idpLoginUrl = `${self.origin}/login`;
err.idpLoginUrl = `${origin}/login`;
err.idpErrorInfo = 'login required';
throw err;

Expand All @@ -120,7 +113,10 @@ function generateAssertion(contents, origin, options) {

} else {
return {
idp,
idp: {
domain: location.host,
protocol: 'mock-idp.js'
},
assertion: assertionStr
};
}
Expand All @@ -141,8 +137,8 @@ function generateAssertion(contents, origin, options) {
function validateAssertion(assertionStr, origin) {
const assertion = JSON.parse(assertionStr);

const { param, query } = assertion;
const { contents, options } = param;
const { args, query } = assertion;
const { contents, options } = args;

const identity = options.usernameHint;

Expand Down Expand Up @@ -188,10 +184,10 @@ function validateAssertion(assertionStr, origin) {
};
*/

// if global.rtcIdentityProvider is defined, and the caller do not ask
// if rtcIdentityProvider is defined, and the caller do not ask
// to not register through query string, register our assertion callbacks.
if(global.rtcIdentityProvider && query.action !== 'do-not-register') {
global.rtcIdentityProvider.register({
if(rtcIdentityProvider && query.action !== 'do-not-register') {
rtcIdentityProvider.register({
generateAssertion,
validateAssertion
});
Expand Down

0 comments on commit 9e3abe2

Please sign in to comment.