Bug 1966586 - Reuse other browser windows when opening _blank links in Taskbar Tabs windows. r=nrishel
This doesn't affect other tab additions, nor does it stop the tab bar
from appearing altogether. The idea is that _if_ another tab is somehow
made, the user should see it; but we should not create new tabs if we
can avoid it.
This also adds tests for opening URIs in popups and taskbar tabs to make
it less likely that this breaks in future.
Differential Revision: https://phabricator.services.mozilla.com/D253726
<!DOCTYPE html><title>clipboard event handlers for MathML</title><linkrel="help"href="https://w3c.github.io/mathml-core/#dom-and-javascript"/><linkrel="help"href="https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers"/><linkrel="help"href="https://w3c.github.io/clipboard-apis/#clipboard-event-copy"/><linkrel="help"href="https://w3c.github.io/clipboard-apis/#clipboard-event-cut"/><linkrel="help"href="https://w3c.github.io/clipboard-apis/#clipboard-event-paste"/><metaname="assert"content="MathMLElements incorporates oncopy / oncut / onpaste event handlers"/><scriptsrc="/resources/testharness.js"></script><scriptsrc="/resources/testharnessreport.js"></script><divid="log"></div><mathoncopy="window.copyHappened1 = true"oncut="window.cutHappened1 = true"onpaste="window.pasteHappened1 = true"><mi>E</mi></math><script>constEVENTS=["copy","cut","paste"];constel=document.querySelector("math");functiondispatchEventTest(name){constmathEl=document.createElementNS("http://www.w3.org/1998/Math/MathML","math");test(()=>{lettarget=undefined;mathEl[`on${name}`]=(e)=>{target=e.currentTarget;}constevent=newClipboardEvent(name,{bubbles:true,cancellable:true});mathEl.dispatchEvent(event);assert_equals(target,mathEl,"The event must be fired at the <math> element");},`${name}: dispatching an Event at a <math> element must trigger element.on${name}`);}functionevaluatedHandlerTest(name){consthandlerName="on"+name;test(()=>{constcompiledHandler=el[handlerName];assert_equals(typeofcompiledHandler,"function",`The ${handlerName} property must be a function`);compiledHandler();assert_true(window[`${name}Happened1`],"Calling the handler must run the code");},`${handlerName}: the content attribute must be compiled into a function as the corresponding property`);test(()=>{constmathEl=document.createElementNS("http://www.w3.org/1998/Math/MathML","math");assert_equals(mathEl[handlerName],null,`The ${handlerName} property must be null (no attribute)`);mathEl.setAttribute(handlerName,`window.${handlerName}Happened2 = true;`);constcompiledHandler=mathEl[handlerName];assert_equals(typeofcompiledHandler,"function",`The ${handlerName} property must be a function (set attribute)`);compiledHandler();assert_true(window[`${handlerName}Happened2`],"Calling the handler must run the code (set attribute)");window[`${handlerName}Happened2`]=false;constclonedMathEl=mathEl.cloneNode(true);constclonedCompiledHandler=clonedMathEl[handlerName];assert_equals(typeofclonedCompiledHandler,"function",`The ${handlerName} property must be a function (clone node)`);clonedCompiledHandler();assert_true(window[`${handlerName}Happened2`],"Calling the handler must run the code (clone node)");mathEl.setAttribute(handlerName,`window.${handlerName}Happened3 = true;`);constnewCompiledHandler=mathEl[handlerName];assert_equals(typeofnewCompiledHandler,"function",`The ${handlerName} property must be a function (modify attribute)`);newCompiledHandler();assert_true(window[`${handlerName}Happened3`],"Calling the handler must run the code (modify attribute)");mathEl.removeAttribute(handlerName);assert_equals(mathEl[handlerName],null,`The ${handlerName} property must be null (remove attribute)`);},`${handlerName}: dynamic changes on the attribute`);}EVENTS.forEach(name=>{dispatchEventTest(name);evaluatedHandlerTest(name);});</script>