Skip to content

Commit

Permalink
Apply clang-format to all JS files (#366)
Browse files Browse the repository at this point in the history
Reformat all JavaScript code written in this repository to use the
clang-format's "Chromium" formatting style.

This is intended to be a non-functional change that contributes
to the effort tracked by #264.
  • Loading branch information
emaxx-google authored Jul 27, 2021
1 parent bc90b1d commit a9d5ca8
Show file tree
Hide file tree
Showing 83 changed files with 1,552 additions and 1,696 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -40,8 +41,8 @@ GSC.IntegrationTestController = function() {
/** @type {!goog.testing.PropertyReplacer} */
this.propertyReplacer = new goog.testing.PropertyReplacer;
/** @type {!GSC.NaclModule} */
this.naclModule = new GSC.NaclModule(
NACL_MODULE_PATH, GSC.NaclModule.Type.PNACL);
this.naclModule =
new GSC.NaclModule(NACL_MODULE_PATH, GSC.NaclModule.Type.PNACL);
/** @type {!GSC.Requester} @private */
this.naclModuleRequester_ = new GSC.Requester(
INTEGRATION_TEST_NACL_MODULE_REQUESTER_NAME,
Expand All @@ -60,8 +61,8 @@ GSC.IntegrationTestController.prototype.initAsync = function() {
* @return {!goog.Promise<void>}
*/
GSC.IntegrationTestController.prototype.disposeAsync = function() {
return this.callCpp_('TearDownAll', /*functionArguments=*/[]).thenAlways(
() => {
return this.callCpp_('TearDownAll', /*functionArguments=*/[])
.thenAlways(() => {
this.naclModuleRequester_.dispose();
this.naclModule.dispose();
this.propertyReplacer.reset();
Expand Down Expand Up @@ -102,10 +103,9 @@ GSC.IntegrationTestController.prototype.sendMessageToCppHelper = function(
*/
GSC.IntegrationTestController.prototype.callCpp_ = function(
functionName, functionArguments) {
const remoteCallMessage = new GSC.RemoteCallMessage(
functionName, functionArguments);
const remoteCallMessage =
new GSC.RemoteCallMessage(functionName, functionArguments);
return this.naclModuleRequester_.postRequest(
remoteCallMessage.makeRequestPayload());
};

});
4 changes: 2 additions & 2 deletions common/js/src/app-utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -30,5 +31,4 @@ const GSC = GoogleSmartCard;
GSC.AppUtils.enableSelfAutoLoading = function() {
chrome.runtime.onStartup.addListener(goog.functions.NULL);
};

}); // goog.scope
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -58,9 +59,8 @@ GSC.BackgroundPageUnloadPreventing.enable = function() {
};

function createIFrameElement() {
const iframe = goog.dom.createDom('iframe', {
'src': 'background-page-unload-preventing-iframe.html'
});
const iframe = goog.dom.createDom(
'iframe', {'src': 'background-page-unload-preventing-iframe.html'});
GSC.Logging.checkWithLogger(logger, document.body);
document.body.appendChild(iframe);
}
Expand All @@ -81,13 +81,12 @@ function connectListener(port) {
GSC.Logging.failWithLogger(
logger,
'Unexpectedly received a message from the message port from the ' +
'iframe');
'iframe');
});
}
}

function suspendListener() {
GSC.Logging.failWithLogger(logger, 'Suspend event was received');
}

}); // goog.scope
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -54,7 +55,6 @@ port.onMessage.addListener(function() {
GSC.Logging.failWithLogger(
logger,
'Unexpectedly received a message through the message port from the ' +
'background page');
'background page');
});

}); // goog.scope
4 changes: 2 additions & 2 deletions common/js/src/clipboard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -54,5 +55,4 @@ GSC.Clipboard.copyToClipboard = function(text) {
logger.fine('Copied text of length ' + text.length + ' to clipboard');
return true;
};

}); // goog.scope
7 changes: 3 additions & 4 deletions common/js/src/container-helpers-unittest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2018 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -34,8 +35,7 @@ goog.exportSymbol('testBuildObjectFromMap', function() {
buildObjectFromMap(new Map([['key1', 'value1'], ['key2', 'value2']])),
{key1: 'value1', key2: 'value2'});
// Test cases where keys and/or values are not strings.
assertObjectEquals(
buildObjectFromMap(new Map([['key', 123]])), {key: 123});
assertObjectEquals(buildObjectFromMap(new Map([['key', 123]])), {key: 123});
assertObjectEquals(
buildObjectFromMap(new Map([[123, 'value']])), {123: 'value'});
assertObjectEquals(
Expand Down Expand Up @@ -82,5 +82,4 @@ goog.exportSymbol('testSubstituteArrayBuffersRecursively', function() {
assertEquals(substituteArrayBuffersRecursively(parseInt), parseInt);
assertEquals(substituteArrayBuffersRecursively(Array), Array);
});

}); // goog.scope
9 changes: 5 additions & 4 deletions common/js/src/container-helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2018 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -33,8 +34,9 @@ const GSC = GoogleSmartCard;
GSC.ContainerHelpers.buildObjectFromMap = function(map) {
let obj = {};
for (let [key, value] of map) {
GSC.Logging.check(typeof key === 'string' || typeof key === 'number',
'Invalid type for object key');
GSC.Logging.check(
typeof key === 'string' || typeof key === 'number',
'Invalid type for object key');
obj[key] = value;
}
return obj;
Expand Down Expand Up @@ -64,5 +66,4 @@ GSC.ContainerHelpers.substituteArrayBuffersRecursively = function(value) {
}
return value;
};

}); // goog.scope
8 changes: 4 additions & 4 deletions common/js/src/deferred-processor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -92,8 +93,8 @@ const DeferredProcessor = GSC.DeferredProcessor;

goog.inherits(DeferredProcessor, goog.Disposable);

DeferredProcessor.prototype.logger = GSC.Logging.getScopedLogger(
'DeferredProcessor');
DeferredProcessor.prototype.logger =
GSC.Logging.getScopedLogger('DeferredProcessor');

/**
* This structure is used to store the jobs in a queue.
Expand Down Expand Up @@ -196,5 +197,4 @@ DeferredProcessor.prototype.flushEnqueuedJobs_ = function() {
GSC.Logging.checkWithLogger(this.logger, this.isCurrentlyFlushingJobs_);
this.isCurrentlyFlushingJobs_ = false;
};

}); // goog.scope
33 changes: 18 additions & 15 deletions common/js/src/executable-module/emscripten-module.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -81,13 +82,15 @@ EmscriptenModule.prototype.getLogger = function() {

/** @override */
EmscriptenModule.prototype.startLoading = function() {
this.load_().then(() => {
this.loadPromiseResolver_.resolve();
}, (e) => {
this.logger_.warning('Failed to load the Emscripten module: ' + e);
this.dispose();
this.loadPromiseResolver_.reject(e);
});
this.load_().then(
() => {
this.loadPromiseResolver_.resolve();
},
(e) => {
this.logger_.warning('Failed to load the Emscripten module: ' + e);
this.dispose();
this.loadPromiseResolver_.reject(e);
});
};

/** @override */
Expand Down Expand Up @@ -144,8 +147,9 @@ EmscriptenModule.prototype.load_ = async function() {
// side and is used for exchanging messages with it. By convention (see the
// entry_point_emscripten.cc files), the class is named GoogleSmartCardModule.
const GoogleSmartCardModule = emscriptenApiModule['GoogleSmartCardModule'];
GSC.Logging.checkWithLogger(this.logger_, GoogleSmartCardModule,
'GoogleSmartCardModule class not defined');
GSC.Logging.checkWithLogger(
this.logger_, GoogleSmartCardModule,
'GoogleSmartCardModule class not defined');
this.googleSmartCardModule_ = new GoogleSmartCardModule((message) => {
this.messageChannel_.onMessageFromModule(message);
});
Expand Down Expand Up @@ -247,8 +251,8 @@ EmscriptenModuleMessageChannel.prototype.disposeInternal = function() {
* @param {?} googleSmartCardModule
* @package
*/
EmscriptenModuleMessageChannel.prototype.onModuleCreated =
function(googleSmartCardModule) {
EmscriptenModuleMessageChannel.prototype.onModuleCreated = function(
googleSmartCardModule) {
this.googleSmartCardModule_ = googleSmartCardModule;
// Send all previously enqueued messages. Note that, in theory, new items
// might be added to the array while we're iterating over it, which should be
Expand All @@ -262,8 +266,8 @@ EmscriptenModuleMessageChannel.prototype.onModuleCreated =
* @param {?} message
* @package
*/
EmscriptenModuleMessageChannel.prototype.onMessageFromModule =
function(message) {
EmscriptenModuleMessageChannel.prototype.onMessageFromModule = function(
message) {
const typedMessage = GSC.TypedMessage.parseTypedMessage(message);
if (!typedMessage) {
GSC.Logging.fail(
Expand All @@ -284,5 +288,4 @@ EmscriptenModuleMessageChannel.prototype.sendNow_ = function(message) {
// Closure Compiler doesn't rename this method call.
this.googleSmartCardModule_['postMessage'](message);
};

}); // goog.scope
10 changes: 5 additions & 5 deletions common/js/src/executable-module/executable-module.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -58,16 +59,16 @@ const TOOLCHAIN = goog.define('GoogleSmartCard.ExecutableModule.TOOLCHAIN', '');
GSC.Logging.check(
Object.values(GSC.ExecutableModule.Toolchain).includes(TOOLCHAIN),
'Unexpected value of GoogleSmartCard.ExecutableModule.TOOLCHAIN: ' +
'`${TOOLCHAIN}`');
'`${TOOLCHAIN}`');
/**
* The toolchain that is used for building the executable module. This constant
* is coming from the build scripts, which take it from the "TOOLCHAIN"
* environment variable.
* @type {!ExecutableModule.Toolchain}
* @const
*/
ExecutableModule.TOOLCHAIN = /** @type {!ExecutableModule.Toolchain} */ (
TOOLCHAIN);
ExecutableModule.TOOLCHAIN =
/** @type {!ExecutableModule.Toolchain} */ (TOOLCHAIN);

/**
* @abstract
Expand Down Expand Up @@ -99,5 +100,4 @@ ExecutableModule.prototype.getLoadPromise = function() {};
* @return {!goog.messaging.AbstractChannel}
*/
ExecutableModule.prototype.getMessageChannel = function() {};

}); // goog.scope
4 changes: 2 additions & 2 deletions common/js/src/fixed-size-integer-unittest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -35,5 +36,4 @@ goog.exportSymbol('testCastToInt32', function() {
assertEquals(-0x80000000, castToInt32(-0x80000000));
assertEquals(-0x7FFFFFFF, castToInt32(0x80000001));
});

}); // goog.scope
4 changes: 2 additions & 2 deletions common/js/src/fixed-size-integer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -30,5 +31,4 @@ const GSC = GoogleSmartCard;
GSC.FixedSizeInteger.castToInt32 = function(value) {
return goog.math.Integer.fromNumber(value).toInt();
};

}); // goog.scope
4 changes: 2 additions & 2 deletions common/js/src/i18n-unittest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @license
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -152,5 +153,4 @@ goog.exportSymbol('testI18n', {
checkSpanNodeTranslated();
},
});

}); // goog.scope
Loading

0 comments on commit a9d5ca8

Please sign in to comment.