Skip to content

Commit

Permalink
Remove registerElementForTesting
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Voytenko committed Aug 22, 2017
1 parent f821c3b commit afbbe1e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 53 deletions.
47 changes: 0 additions & 47 deletions src/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ setReportError(reportErrorForWin.bind(null, self));
/** @const @private {string} */
const TAG = 'runtime';

/** @type {!Object} */
const elementsForTesting = {};

/**
* Install runtime-level services.
Expand Down Expand Up @@ -487,13 +485,6 @@ function prepareAndRegisterElementShadowMode(global, extensions,
*/
function registerElementClass(global, name, implementationClass, opt_css) {
registerExtendedElement(global, name, implementationClass);
if (getMode().test) {
elementsForTesting[name] = {
name,
implementationClass,
css: opt_css,
};
}
// Register this extension to resolve its Service Promise.
registerServiceBuilder(global, name, emptyService);
}
Expand Down Expand Up @@ -980,44 +971,6 @@ function emptyService() {
}


/**
* Registers all extended elements as normal elements in the given
* window.
* Make sure to call `adopt(window)` in your unit test as well and
* then call this on the generated iframe.
* @param {!Window} win
*/
export function registerForUnitTest(win) {
for (const key in elementsForTesting) {
let element = null;
element = elementsForTesting[key];
if (element.css) {
installStyles(win.document, element.css, () => {
registerElement(win, element.name, element.implementationClass);
}, false, element.name);
} else {
registerElement(win, element.name, element.implementationClass);
}
}
}


/**
* Registers a specific element for testing.
* @param {!Window} win
* @param {string} elementName
* @visibleForTesting
*/
export function registerElementForTesting(win, elementName) {
const element = elementsForTesting[elementName];
if (!element) {
throw new Error('test element not found: ' + elementName +
'\nKnown elements ' + Object.keys(elementsForTesting).sort());
}
win.AMP.registerElement(element.name, element.implementationClass,
element.css);
}

/**
* For a given extension, checks that its version is the same
* as the version of the main AMP binary.
Expand Down
3 changes: 0 additions & 3 deletions testing/describes.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ import {
adoptShadowMode,
installAmpdocServices,
installRuntimeServices,
registerElementForTesting,
} from '../src/runtime';
import {createElementWithAttributes} from '../src/dom';
import {addParamsToUrl} from '../src/url';
Expand Down Expand Up @@ -687,8 +686,6 @@ class AmpFixture {
const installer = extensionsBuffer[`${extensionId}:${version}`];
if (installer) {
registerExtension(env.extensions, extensionId, installer, win.AMP);
} else {
registerElementForTesting(win, extensionId);
}
});
}
Expand Down
3 changes: 0 additions & 3 deletions testing/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {parseIfNeeded} from '../src/iframe-helper';
import {
installAmpdocServices,
installRuntimeServices,
registerForUnitTest,
} from '../src/runtime';
import installCustomElements from
'document-register-element/build/document-register-element.node';
Expand Down Expand Up @@ -233,7 +232,6 @@ export function createIframePromise(opt_runtimeOff, opt_beforeLayoutCallback) {
installRuntimeServices(iframe.contentWindow);
installCustomElements(iframe.contentWindow);
installAmpdocServices(ampdoc);
registerForUnitTest(iframe.contentWindow);
Services.resourcesForDoc(ampdoc).ampInitComplete();
// Act like no other elements were loaded by default.
installStyles(iframe.contentWindow.document, cssText, () => {
Expand Down Expand Up @@ -285,7 +283,6 @@ export function createServedIframe(src) {
win.AMP_TEST_IFRAME = true;
win.AMP_TEST = true;
installRuntimeServices(win);
registerForUnitTest(win);
resolve({
win: win,
doc: win.document,
Expand Down

0 comments on commit afbbe1e

Please sign in to comment.