How add style sheet to content of <browser> element in Firefox? - firefox-addon-sdk

How add style sheet to content of element in Firefox?
This not working:
https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/stylesheet_utils
Skips element content of element.

loadSheet(window, uri, type)
content of <browser> element
if browserElement is xul browser element,
then browserElement.contentWindow is a window (or nsIDOMWindow)
loadSheet(browserElement.contentWindow, uri, type)
It works. Just like switching off and switching on the sidebar, it's already this style does not load
sidebarWindow.addEventListener("load", function() {console.log("sidebear.test");});

Related

using Serenity-js framework ,how to locate a shadow element whose parent has an id which is a normal DOM

please tell me how i can locate an element in the below form using serenity-js Target.
Below is my Dom to the page i am trying to automate.
so here its a dropdown which you can see as which has id="splc" which is a normal DOM .. but the content inside that dropdown are all shadow elements.
my requirement is to access the content in dropdown.
Now i am not able to even click on the dropdown by normal xpath on px-component tag ( which is normal DOM) .
Inside that px component tag I can see that it has a shadow element #label which is exact element i need to click.
Problem is in my html page , all the dropdown has the same #label as the shadow element and their parent is a normal xpath with unique id.
When i use the Jquery on the chrome console
$("html #splc /deep/ div#label").click()
i can click the desired dropdown.
But how can i do the same with serenity-js frame work.
i want to do the below functionality that i have in protractor using SERENITY-JS concept .
static dropdown = element(by.id("splc")).element(by.deepCss("#label"));
Since serenity-js expects a target always since the Task needs that in activity. How can do the same ?
please help me.
From what I can see, by.deepCss is nothing more than a wrapper around by.css:
deepCss(selector: string): Locator {
return By.css('* /deep/ ' + selector);
};
If that's the case, then the following:
element(by.id("splc")).element(by.deepCss("#label"))
could be represented as:
element(by.css("#splc /deep/ #label"))
as per your jQuery example.
Now, if the above works, you should be able to define a Target as follows:
const Dropdown = Target.the('Dropdown').located(by.css("#splc /deep/ #label"))
Hope this helps!
Jan

How to configure TinyMCE to allow block-level elements inside inline element?

I have an HTML where inline element span which hold block element example div. I have pasted below HTML source in the source view of TinyMCE and press Ok
<span>plain text<div>test div</div></span>​
Further, I have click on the source view and HTML it changes to the below HTML where span automatically gets closed and new span added to the HTML,
<p><span><span>plain text</span></span></p>
<div>test div</div>
<p>​</p>
I know, we can't have block element inside the inline element(i.e. HTML global rule), but I am not in position to make changes in the current system.
Update: I have tried to solution mention here but not worked well: https://stackoverflow.com/a/14603631/4420468
There is a config option to control this behavior.
valid_children
The valid_children enables you to control what child elements can exists within specified parent elements.
see docs for further information

Cannot programmatically add content to simple HTML DIV Element in XML view

I have a simple XML view (fragment) like this:
<html:div id="holder"></html:div>
I want to add content programmatically like this:
var holder = this.byId("holder");
var label = new sap.m.Label({
text: "Label"
});
holder.addContent(label);
Effect is nothing, no error, no added content.
Why does it not work?
This is because content is not an aggregation (an easy mistake to make, since content usually is an aggregation).
sap.ui.core.HTML's content metadata object is a property of type string. From the jsdoc:
HTML content to be displayed, defined as a string.
You will need to use a different container for your label, such as sap.ui.layout.VerticalLayout, or you could just use raw HTML to stick in your holder object, rather than that sap.m.Label type.
Here is a jsbin that takes the XML view part of this question out of the equation.
Note: See #hirse's comment below for an important distinction when using html:div in XML views
The HTML element and the UI5 Controls are not directly compatible. UI5 Controls are JavaScript objects that have a render function. The render function creates a html fragment on demand. That html fragment ist then inserted into the page.
I have never tried it, but a solution could be to use the placeAt() method of your label:
label.placeAt("holder");
If you are using an XML View, the holder id will be prefixed. Then you should use something like this:
label.placeAt(this.getView().createId("holder"));
You can get DOM element of UI5 control by using getDomRef of sap.ui.core.Element class.
Then add your content to this DOM element by using placeAt()
Here is working example.

Setting the header of a content element to the page title

I have some subpages where there is a single content element with a header in HTML H1.
How can I set the header of this content element to the page's title?
We used a typoscript marker for that. Just define it in your page template and then fill it with the title like this:
PAGE-TITLE = TEXT
PAGE-TITLE.field = nav_title // subtitle // title
Instead of relying on Content Element (CE) (which de facto may exist OR not AND can have any header set OR not) it's better to... use Michael's suggestion and on the selected branch use the modified template, and place ###PAGE-TITLE### marker just before the marker where you are rendering-in your ContentElements.
In that case you don't need to modify the way that your <title> tag is created and you have sure that title always exists and you can be sure that there's always some title.
Of course you'll need to set the default header of the first CE as hidden (or leave it empty), however you can do it for whole branch with PageTS.

Watin - How to set value of textarea (HTML editor)?

I'm trying to set the value of a textfield using the following code:
if (ie.TextField(Find.ById("testField")).Exists)
ie.TextField(Find.ById("testField")).Value = "Test";
The code passes without raising an error, however the textfield is not filled with the value.
I get an exception when I execute the following line:
ie.TextField(Find.ById("testField")).Focus()
The textarea is a tiny_mce editor and one of the html attributes is: style="display: none;"...
Any ideas how I can modify the value of such a field using Watin?
Thanks.
First tinymce is not a textarea. tinymce hides your textarea on initialization and creates a contenteditable iframe which is then used to allow text editing, styling aso...
Second if you want to write the editors content back to the hidden textarea you may do this using
tinymce.get('testField').triggerSave();.
Another way to set the value of your textarea is:
tinymce.get('testField').getDocumentById('testField').value = 'new value';
In case you want to write content directly to your tinymce editor you may choose on of the following
tinymce.get('testField').setContent('my_new_content'); // replaces the editors content
or
tinymce.get('testField').execCommand('mceInsertContent',false, 'my_content_to_be_added'); // adds the content at the carat postion
Here is a simple way to handle this using the Watin Eval function:
var js = "tinyMCE.get('body').setContent('" + bodyCont + "')";
var s = ie.Eval(js);
'body' needs to replaced with the id of the textarea that is hidden by tinymce - do a "view source" in your browser window to find this id.