Skip to content

Instantly share code, notes, and snippets.

View sbabcoc's full-sized avatar
💭
All I Really Need to Know I Learned in Kindergarten

Scott Babcock sbabcoc

💭
All I Really Need to Know I Learned in Kindergarten
View GitHub Profile

Q: What's driving this — contributing full Shadow DOM support upstream to HtmlUnit itself, or just getting HtmlUnit(Driver) far enough to test your own shadow-DOM-based pages?
A: Upstream contribution to HtmlUnit/htmlunit

Q: How much of the spec actually matters for your use case?
A: Full spec: closed mode, CSS encapsulation, event retargeting, declarative shadow DOM

Good — that confirms the scope. A few more things worth knowing before any code gets written:

  • DomNode.querySelector() (the core query engine, ~2200 lines) has no shadow-boundary awareness — it would need to become shadow-tree-scoped by default, with an explicit "deep" path for things like getElementById semantics across the tree.
  • The CSS engine isn't part of HtmlUnit itself — it's htmlunit-cssparser, a separate library, also maintained by Ronald Brill (rbri), same for the HTML parser (neko-htmlunit). Full CSS encapsulation (:host, :host(), ::slotted, and correctly not leaking outer-page styles into the sha

I want to see if we can add Shadow DOM support to the HtmlUnit headless browser.

I dug into the actual HtmlUnit/htmlunit source (cloned master) rather than go on general knowledge, since this is exactly the kind of thing that goes stale. Here's where it actually stands:

Current state (much thinner than it looks):

  • org.htmlunit.javascript.host.dom.ShadowRoot exists — but it's a bare stub: extends DocumentFragment, has a constructor and nothing else. No host, no mode, no innerHTML override.
  • Element.attachShadow() does not exist at all. There's a comment in Element.getInnerHTML()/getOuterHTML() that literally says // ignore the params because we have no shadow dom support so far.
  • <slot> (HtmlSlot / HTMLSlotElement) is registered as a tag with display: contents, but there's no slot-distribution algorithm — no assignedNodes(), no assignedSlot, no slotchange event.
  • CustomElementRegistry exists as a JS class but has no define() method — Custom Elements ar

Here is a comprehensive T-SQL (Transact-SQL) cheat sheet designed for quick reference. It covers everything from basic querying to SQL Server-specific features like CTEs, Window Functions, and error handling.


1. Query Order of Execution

Understanding the order in which SQL Server processes a query is crucial for debugging performance and logic errors.

  1. FROM / JOIN (Gathering data)
  2. WHERE (Filtering rows)

Coming from Java, you’ll find that TypeScript feels incredibly familiar but with a few "dynamic" twists. TypeScript brings the static typing and object-oriented principles you know from Java, but compiles down to JavaScript.

The biggest mental shift is that Java uses nominal typing (types are matched by name/inheritance), while TypeScript uses structural typing (types are matched by their shape/structure, often called "duck typing").

Here is how core software patterns and implementations translate from Java to TypeScript.


1. Classes, Interfaces, and Dependency Injection

Yes, you can replicate this kind of Intent verification in an integration test, where you validate that your application actually sends an intent to the system as part of its behavior when interacting with the UI. For integration testing with intents, Espresso-Intents is often the go-to library in Android. Here’s how you can use Espresso-Intents for integration testing of intent actions.

Integration Testing Intents with Espresso-Intents

Espresso-Intents lets you intercept and verify outgoing intents without actually launching the external application (like the browser). This approach is more robust in integration tests because it ensures your app is interacting correctly with the Android system.

Steps to Set Up and Use Espresso-Intents

  1. Add Espresso-Intents Dependency Ensure you have Espresso-Intents in your build.gradle file for your androidTest scope:

Certainly! When you use Mockito for testing intent actions, you're primarily concerned with verifying that your application correctly creates and sends the Intent for specific actions (like opening a URL in a browser). Here’s a breakdown of how to set up and use Mockito to test Intent actions in Android:

Step-by-Step Guide to Mocking Intents with Mockito

  1. Add Mockito Dependencies Ensure you have the necessary dependencies for Mockito in your build.gradle file:

    testImplementation 'org.mockito:mockito-core:4.x.x'
    testImplementation 'org.mockito:mockito-inline:4.x.x' // For mocking final classes/methods
@sbabcoc
sbabcoc / gist:a352393751df63a340840f89244cb5a5
Last active September 6, 2024 19:31
How to add arbitrary headers to HTTP requests

In Selenium 4, you can add arbitrary headers to HTTP requests using the DevTools protocol, which is now integrated into Selenium. Here's how you can do it with Chrome or Edge:

Example in Java (Selenium 4):

  1. Set up the ChromeDriver or EdgeDriver:
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.devtools.DevTools;
@sbabcoc
sbabcoc / XCUITest page components.md
Last active February 1, 2024 01:08
XCUITest page components
layout post
title XCUITest Automation: Page Components for iOS Test Automation
category mobile
author Scott Babcock
tags
xcuitest
mobile
swift
summary-image /articles/xcuitest/XCUITest.jpg

Creating Stable, Maintainable User Interface Test Automation in Swift

@sbabcoc
sbabcoc / XCUITest page object models.md
Last active January 31, 2024 20:48
XCUITest page object models
layout post
title XCUITest Automation: Page Object Models for iOS Test Automation
category mobile
author Scott Babcock
tags
xcuitest
mobile
swift
summary-image /articles/xcuitest/XCUITest.jpg

Creating Stable, Maintainable User Interface Test Automation in Swift

@sbabcoc
sbabcoc / XCUITest element locator enums.md
Last active February 24, 2024 18:50
XCUITest element locator enums
layout post
title XCUITest Automation: Encapsulating Element Locators in Swift Enumerations
category mobile
author Scott Babcock
tags
xcuitest
mobile
swift
summary-image /articles/xcuitest/XCUITest.jpg

Creating Stable, Maintainable User Interface Test Automation in Swift