Skip to content

Commit

Permalink
Inabox: remove unnecessary dependency on storage services. (ampprojec…
Browse files Browse the repository at this point in the history
…t#22888)

* Inabox: remove unnecessary dependencies cid & storage services.

* Undo CID

* Undo CID
  • Loading branch information
lannka authored Jun 27, 2019
1 parent eb6b8e1 commit 73fb591
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/inabox/amp-inabox.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {installViewerServiceForDoc} from '../service/viewer-impl';
import {internalRuntimeVersion} from '../internal-version';
import {isExperimentOn} from '../experiments';
import {maybeValidate} from '../validator-integration';
import {rejectServicePromiseForDoc} from '../service';
import {startupChunk} from '../chunk';
import {stubElementsForDoc} from '../service/custom-element-registry';

Expand Down Expand Up @@ -93,6 +94,9 @@ startupChunk(self.document, function initial() {
fullCss,
() => {
startupChunk(self.document, function services() {
// For security, storage is not supported in inabox.
// Fail early with console errors for any attempt of access.
unsupportedService(ampdoc, 'storage');
// Core services.
installRuntimeServices(self);
fontStylesheetTimeout(self);
Expand Down Expand Up @@ -150,3 +154,15 @@ self.document.documentElement.setAttribute(
'amp-version',
internalRuntimeVersion()
);

/**
* @param {!../service/ampdoc-impl.AmpDoc} ampdoc
* @param {string} name
*/
function unsupportedService(ampdoc, name) {
rejectServicePromiseForDoc(
ampdoc,
name,
new Error('Un-supported service: ' + name)
);
}
5 changes: 4 additions & 1 deletion src/service/core-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ export function installAmpdocServices(ampdoc, opt_initParams, opt_inabox) {
installUrlReplacementsServiceForDoc(ampdoc);
installActionServiceForDoc(ampdoc);
installStandardActionsForDoc(ampdoc);
installStorageServiceForDoc(ampdoc);
if (!opt_inabox) {
// For security, Storage is not supported in inabox.
installStorageServiceForDoc(ampdoc);
}
installGlobalNavigationHandlerForDoc(ampdoc);
installGlobalSubmitListenerForDoc(ampdoc);
}

0 comments on commit 73fb591

Please sign in to comment.