use of elemental2.dom.Document in project tapestry-5 by apache.
the class TestableResponseImplTest method http_headers.
@Test
public void http_headers() {
Document document = tester.renderPage(TestPageForHttpHeaders.class.getSimpleName());
assertTrue(document.toString().contains("Test page for HTTP headers"));
TestableResponse response = tester.getService(TestableResponse.class);
assertEquals(response.getHeader(TestPageForHttpHeaders.DATE_HEADER_NAME), 12345L);
assertEquals(response.getHeader(TestPageForHttpHeaders.INT_HEADER_NAME), 6789);
assertEquals(response.getHeader(TestPageForHttpHeaders.STRING_HEADER_NAME), "foo-bar-baz-barney");
}
use of elemental2.dom.Document in project console by hal.
the class StartAnalytics method call.
@Override
public Completable call(FlowContext context) {
String pathname = window.location.getPathname();
boolean testSuite = pathname.endsWith("ts.html");
boolean collectUserData = settings.get(COLLECT_USER_DATA).asBoolean();
if (!testSuite && collectUserData) {
String id;
if (environment.isDevMode()) {
id = DEVELOPMENT_ID;
} else if (environment.isProductionMode()) {
id = PRODUCTION_ID;
} else {
id = UNKNOWN_ID;
}
HTMLScriptElement script = (HTMLScriptElement) document.createElement("script");
script.text = "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', " + stringify(config(id)) + ");";
document.head.appendChild(script);
GoogleAnalytics ga = new GoogleAnalytics();
ga.customDimension(1, environment.getAccessControlProvider().name().toLowerCase());
ga.customDimension(2, environment.getHalBuild().name().toLowerCase());
ga.customDimension(3, environment.getHalVersion().toString());
ga.customDimension(4, environment.getManagementVersion().toString());
ga.customDimension(5, environment.getOperationMode().name().toLowerCase());
ga.customDimension(6, environment.getInstanceInfo().productName());
ga.customDimension(7, environment.getInstanceInfo().productVersion());
ga.customDimension(8, environment.getInstanceInfo().releaseName());
ga.customDimension(9, environment.getInstanceInfo().releaseVersion());
ga.customDimension(10, endpoints.isSameOrigin());
ga.customDimension(11, environment.isSingleSignOn());
ga.customDimension(12, settings.get(LOCALE).value());
Tracker tracker = new Tracker(ga);
eventBus.addHandler(NavigationEvent.getType(), tracker);
eventBus.addHandler(FinderContextEvent.getType(), tracker);
eventBus.addHandler(ModelBrowserPathEvent.getType(), tracker);
logger.info("Collect user data is on: {}", id);
} else {
logger.info("Collect user data is off.");
}
return Completable.complete();
}
use of elemental2.dom.Document in project kie-wb-common by kiegroup.
the class DMNEditDRDToolboxActionTest method testOnMouseClick.
@Test
public void testOnMouseClick() throws NoSuchFieldException, IllegalAccessException {
final HTMLElement htmlElement = new HTMLElement();
htmlElement.style = new CSSStyleDeclaration();
final HTMLDocument htmlDocument = new HTMLDocument();
htmlDocument.body = new HTMLBodyElement();
final Field field = DomGlobal.class.getDeclaredField("document");
field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(DomGlobal.class, htmlDocument);
when(drdContextMenu.getElement()).thenReturn(htmlElement);
dmnEditDRDToolboxAction.onMouseClick(canvasHandler, UUID, mouseClickEvent);
verify(drdContextMenu, times(1)).show(Mockito.<Collection>any());
}
use of elemental2.dom.Document in project kie-wb-common by kiegroup.
the class DocumentUpload method doUpload.
@Override
public void doUpload(final Document document, File file) {
if (!enabled) {
return;
}
DocumentData documentData = new DocumentData(document.getId(), document.getName(), document.getSize(), document.getUrl(), (long) document.getLastModified());
DocumentPreview preview = render(documentData);
DocumentPreviewStateActionsHandlerImpl handler = new DocumentPreviewStateActionsHandlerImpl(DocumentPreviewState.PENDING);
DocumentPreviewStateAction abortAction = new DocumentPreviewStateAction(translationService.getTranslation(Constants.DocumentUploadViewImplAbort), () -> uploader.remove(document.getId(), () -> doRemove(preview)));
handler.addStateActions(DocumentPreviewState.UPLOADING, Collections.singletonList(abortAction));
DocumentPreviewStateAction removeAction = new DocumentPreviewStateAction(translationService.getTranslation(Constants.DocumentUploadViewImplRemove), () -> uploader.remove(document.getId(), () -> doRemove(preview)));
handler.addStateActions(DocumentPreviewState.PENDING, Collections.singletonList(removeAction));
handler.addStateActions(DocumentPreviewState.UPLOADED, Collections.singletonList(removeAction));
final Command startUploadCallback = () -> handler.notifyStateChange(DocumentPreviewState.UPLOADING);
final ParameterizedCommand<Boolean> onFinishUpload = success -> {
if (success) {
handler.notifyStateChange(DocumentPreviewState.UPLOADED);
} else {
handler.notifyStateChange(DocumentPreviewState.ERROR);
}
};
DocumentPreviewStateAction retryAction = new DocumentPreviewStateAction(translationService.getTranslation(Constants.DocumentUploadViewImplRetry), () -> {
uploader.remove(document.getId(), () -> uploader.upload(document.getId(), file, startUploadCallback, onFinishUpload));
});
handler.addStateActions(DocumentPreviewState.ERROR, Arrays.asList(removeAction, retryAction));
preview.setStateHandler(handler);
uploader.upload(document.getId(), file, startUploadCallback, onFinishUpload);
ValueChangeEvent.fire(DocumentUpload.this, getValue());
}
use of elemental2.dom.Document in project kie-wb-common by kiegroup.
the class PrintHelperTest method testChangeMediaAttributesToAll.
@Test
public void testChangeMediaAttributesToAll() {
final HTMLDocument document = mock(HTMLDocument.class);
final Element element = mock(Element.class);
final NodeList<Element> links = spy(new NodeList<>());
final String media = "media";
links.length = 1;
doReturn(element).when(links).item(0);
doReturn(element).when(helper).asElement(element);
when(document.querySelectorAll("link")).thenReturn(links);
when(element.getAttribute(media)).thenReturn("print");
helper.changeMediaAttributesToAll(document);
verify(element).setAttribute(media, "all");
}
Aggregations