Returns a CSS response that hides all elements on the page and
 displays the exception
497374
def css_exception_response(exception)
        message   = "\n#{exception.class.name}: #{exception.message}"
        backtrace = "\n  #{exception.backtrace.first}"

        body = <<-CSS
          html {
            padding: 18px 36px;
          }

          head {
            display: block;
          }

          body {
            margin: 0;
            padding: 0;
          }

          body > * {
            display: none !important;
          }

          head:after, body:before, body:after {
            display: block !important;
          }

          head:after {
            font-family: sans-serif;
            font-size: large;
            font-weight: bold;
            content: "Error compiling CSS asset";
          }

          body:before, body:after {
            font-family: monospace;
            white-space: pre-wrap;
          }

          body:before {
            font-weight: bold;
            content: "#{escape_css_content(message)}";
          }

          body:after {
            content: "#{escape_css_content(backtrace)}";
          }
        CSS

        [ 200, { "Content-Type" => "text/css; charset=utf-8", "Content-Length" => body.bytesize.to_s }, [ body ] ]
      end
1166177
def wait_for_element_absent(self, selector, by=By.CSS_SELECTOR,
                                timeout=settings.LARGE_TIMEOUT):
        
        if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
            timeout = self.__get_new_timeout(timeout)
        if page_utils.is_xpath_selector(selector):
            by = By.XPATH
        return page_actions.wait_for_element_absent(
            self.driver, selector, by, timeout)
251725
public void showElement(CmsContainerPageElementPanel elementWidget) {

        int index = 0;
        for (index = 0; index < getGroupContainerWidget().getWidgetCount(); index++) {
            if (CmsDomUtil.hasClass(HIDDEN_ELEMENT_CLASS, getGroupContainerWidget().getWidget(index).getElement())) {
                break;
            }
        }
        getGroupContainerWidget().insert(elementWidget, index);
        elementWidget.getInheritanceInfo().setVisible(true);
        elementWidget.removeStyleName(HIDDEN_ELEMENT_CLASS);
        updateButtonVisibility(elementWidget);
        getGroupContainerWidget().refreshHighlighting();
        List<Element> elements = CmsDomUtil.getElementsByClass(
            HIDDEN_ELEMENT_OVERLAY_CLASS,
            Tag.div,
            elementWidget.getElement());
        for (Element element : elements) {
            element.removeFromParent();
        }
        if (CmsDomUtil.getElementsByClass(
            HIDDEN_ELEMENT_OVERLAY_CLASS,
            Tag.div,
            getGroupContainerWidget().getElement()).isEmpty()) {
            // if no other hidden elements present disable toggle button
            m_showElementsButton.disable(Messages.get().key(Messages.GUI_INHERITANCECONTAINER_NO_HIDDEN_ELEMENTS_0));
        }
        m_changedInheritanceInfo = true;
    }
1093203
function processIssue(issue) {
			return {
				code: issue.code,
				context: processIssueHtml(issue.element),
				message: issue.msg,
				type: issueTypeMap[issue.type] || 'unknown',
				typeCode: issue.type,
				selector: getCssSelectorForElement(issue.element)
			};
		}
832466
function excludeElements(exclude) {
      return Array.isArray(exclude) ? exclude.forEach(function(selector) {
        // Use querySelectorAll to hide all dom element with the specified selector
        var selectorAll = document.querySelectorAll(selector);

        if(selectorAll.length) {
          // Interate through NodeList
          for(var i = 0; i < selectorAll.length; i++) {
            selectorAll.item(i).style.visibility = 'hidden';
          }
        }
      }) : false;
    }
621043
function containsWithoutPseudos(selector, potentialMatch) {
  var classesInPotentialMatch = getCssClasses(potentialMatch).map(stripPseudos)

  return classesInPotentialMatch.some(function (c) {
    return selector === c
  })
}
1215134
function selectorBlockHandler(element) {
    if (element.type === 'Selector') {
        const name = []
        let discard = false
        element.children.forEach(e => {
            switch (e.type) {
                case "ClassSelector":
                    name.push("." + e.name);
                    break;
                    //not support for now
                case "Combinator":
                    name.push(e.name);
                    discard = true
                    return null
                case "TypeSelector":
                    name.push(e.name);
                    break;
                case "IdSelector":
                    //not support for now
                    name.push("#" + e.name);
                    discard = true
                    return null
                case "WhiteSpace":
                    name.push(" ");
                    break
                default: {
                    // console.warn('unknown selector type:', e)
                    discard = true
                    return null
                }
            }
        })
        if (!discard)
            return name.join("")
        else return null
    }
}
315479
def error_code(self, code):
		

		context = {
			'error_title': "Damn error page %i" % code,
			'error_header': "What has happened?",
			'error_footer': "WHY!?!?!",
			'error_messages': {
				('Error %i' % code): self.__message__(code)
			}
		}
		return WWebTemplateResponse(WTemplateText(self.__error_template__()), context=context)
170785
private function getCssArray() {
        if (!$this->hasRequestParameter('cssJson')) {
            throw new common_exception_MissingParameter('cssJson', __CLASS__.'::'.\Context::getInstance()->getActionName());
        }
        $cssArr = json_decode($_POST['cssJson'], true);
        if(!is_array($cssArr)) {
            throw new common_exception_InvalidArgumentType(__CLASS__,\Context::getInstance()->getActionName(), 0, 'json encoded array');
        }
        return $cssArr;

    }
691179
public function exceptionAction() {
		
		// get the exception
		$this->Exception = Store\Request::get('exception');
		// if the exception is not a 404 or a 403 (the most common and non important)
		if(
			$this->Exception->getCode() < 401 || 
			$this->Exception->getCode() > 404
		) {
			// log the exception
			Logger::critical(
				$this->Exception->getCode() . ' '.
				$this->Exception->getMessage(), 
				$this->Exception->getTrace()
			);
		}
		// error occured while requesting something else than html
		if(!in_array(
			Response::getType(), 
			['html','html-page']
		)) {
			// change the type to plaintext
			Response::setType('text');
			// set the stack a string
			Response::setContent(
				$this->Exception->getCode() . "\n".
				$this->Exception->getMessage() . "\n".
				$this->Exception
			);
			// render as is
			Response::render();
		}
		// error occured normally
		else {
			// disable space removal for the trace stack
			Config::set('response','minify', 0);
			// reset already output data (very important, because of content-length)
			Response::setType('html-page');
			// proper title and assets
			Response\HTML::set([
				'metas'		=>[
					'title'=> $this->Exception->getCode() . ', ' . 
						Locales::get($this->Exception->getMessage())
				],
				'scripts'	=>[
					'//code.jquery.com/jquery-3.3.1.slim.min.js',
					'//stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js'
				],
				'links'		=>[
					'//stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css',
					'//use.fontawesome.com/releases/v5.3.1/css/all.css'
				]
			]);
			
			// error is of type forbidden/bad request
			if(
				$this->Exception->getCode() >= 400 && 
				$this->Exception->getCode() <= 403
			) {
				$this->icon = 'fa fa-ban';
			}
			// error is of type internal error
			elseif(
				$this->Exception->getCode() >= 500 && 
				$this->Exception->getCode() <= 599
			) {
				$this->icon = 'fa fa-bug';
			}
			// error is not found
			elseif(
				$this->Exception->getCode() == 404
			) {
				$this->icon = 'fa fa-exclamation-circle';
			}
			// any other type of errors
			else {
				$this->icon = 'fa fa-exclamation-triangle';
			}

			// pass to the exception view
			$this->view('Exception');
		}
			
	}
927993
def render_error(request, exc):
    ''''''
    cfg = request.get('pulsar.cfg')
    debug = cfg.debug if cfg else False
    response = request.response
    if not response.content_type:
        content_type = request.get('default.content_type')
        response.content_type = request.content_types.best_match(
            as_tuple(content_type or DEFAULT_RESPONSE_CONTENT_TYPES)
        )
    content_type = None
    if response.content_type:
        content_type = response.content_type.split(';')[0]
    is_html = content_type == 'text/html'

    if debug:
        msg = render_error_debug(request, exc, is_html)
    else:
        msg = escape(error_messages.get(response.status_code) or exc)
        if is_html:
            msg = textwrap.dedent("""
                <h1>{0[reason]}</h1>
                {0[msg]}
                <h3>{0[version]}</h3>
            """).format({"reason": response.status, "msg": msg,
                         "version": request.environ['SERVER_SOFTWARE']})
    #
    if content_type == 'text/html':
        doc = HtmlDocument(title=response.status)
        doc.head.embedded_css.append(error_css)
        doc.body.append(Html('div', msg, cn='pulsar-error'))
        return doc.to_bytes(request)
    elif content_type in JSON_CONTENT_TYPES:
        return json.dumps({'status': response.status_code,
                           'message': msg})
    else:
        return '\n'.join(msg) if isinstance(msg, (list, tuple)) else msg
708503
def hide_element(self, selector, by=By.CSS_SELECTOR):
        
        selector, by = self.__recalculate_selector(selector, by)
        selector = self.convert_to_css_selector(selector, by=by)
        selector = self.__make_css_match_first_element_only(selector)
        hide_script = """jQuery('%s').hide()""" % selector
        self.safe_execute_script(hide_script)
452170
function getElementsVisibility(elements) {

  var result = {};

  elements.forEach(function(e) {
    result[e.id] = e.hidden;
  });

  return result;
}
163056
public int doEndTag() throws JspException
    {
        Tag parent = getParent();
        if (parent instanceof CheckBoxGroup)
            registerTagError(Bundle.getString("Tags_CheckBoxGroupChildError"), null);

        Object val = evaluateDataSource();
        if (hasErrors())
            return reportAndExit(EVAL_PAGE);

        ByRef ref = new ByRef();
        nameHtmlControl(_state, ref);

        String hiddenParamName = _state.name + OLDVALUE_SUFFIX;
        ServletRequest req = pageContext.getRequest();

        if (val instanceof String) {
            if (val != null && Boolean.valueOf(val.toString()).booleanValue())
                _state.checked = true;
            else
                _state.checked = false;
        }
        else if (val instanceof Boolean) {
            _state.checked = ((Boolean) val).booleanValue();
        }
        else {
            String oldCheckBoxValue = req.getParameter(hiddenParamName);
            if (oldCheckBoxValue != null) {
                _state.checked = new Boolean(oldCheckBoxValue).booleanValue();
            }
            else {
                _state.checked = evaluateDefaultValue();
            }
        }
        _state.disabled = isDisabled();

        //Create a hidden field to store the CheckBox oldValue
        String oldValue = req.getParameter(_state.name);
        WriteRenderAppender writer = new WriteRenderAppender(pageContext);

        // if the checkbox is disabled we need to not write out the hidden
        // field because it can cause the default state to change from
        // true to false.  Disabled check boxes do not postback.
        if (!_state.disabled) {
            _hiddenState.name = hiddenParamName;
            if (oldValue == null) {
                _hiddenState.value = "false";
            }
            else {
                _hiddenState.value = oldValue;
            }
            TagRenderingBase hiddenTag = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_HIDDEN_TAG, req);
            hiddenTag.doStartTag(writer, _hiddenState);
            hiddenTag.doEndTag(writer);
        }

        _state.type = INPUT_CHECKBOX;

        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_BOOLEAN_TAG, req);
        br.doStartTag(writer, _state);

        if (!ref.isNull())
            write((String) ref.getRef());

        // Continue processing this page
        localRelease();
        return EVAL_PAGE;
    }
1362295
protected String postcss(HttpServletRequest request, String css, IResource res) throws IOException {
		if (threadScopes == null) {
			return css;
		}
		Context cx = Context.enter();
		Scriptable threadScope = null;
		String result = null;
		try {
			threadScope = threadScopes.poll(SCOPE_POOL_TIMEOUT_SECONDS, TimeUnit.SECONDS);
			if (threadScope == null) {
				throw new TimeoutException("Timeout waiting for thread scope"); //$NON-NLS-1$
			}
			Scriptable scope = cx.newObject(threadScope);
			scope.setParentScope(threadScope);
			Scriptable postcssInstance = (Scriptable)threadScope.get(POSTCSS_INSTANCE, scope);
			Function postcssProcessor = (Function)postcssInstance.getPrototype().get(PROCESS, postcssInstance);
			Object processed = postcssProcessor.call(cx, scope, postcssInstance, new Object[]{css, postcssOptions});
			result = Context.toString(processed);
		} catch (JavaScriptException e) {
			// Add module info
			String message = "Error parsing " + res.getURI() + "\r\n" + e.getMessage(); //$NON-NLS-1$ //$NON-NLS-2$
			throw new IOException(message, e);
		} catch (InterruptedException e) {
			throw new RuntimeException(e);
		} catch (TimeoutException e) {
			throw new RuntimeException(e);
		}
		finally {
			if (threadScope != null) {
				// put the thread scope back in the queue now that we're done with it
				threadScopes.add(threadScope);
			}
			Context.exit();
		}
		return result;
	}
1089329
public int doEndTag() throws JspException
    {
        ServletRequest req = pageContext.getRequest();

        String fmtErrors = null;
        if (_formatterError) {
            fmtErrors = getErrorsFromBody();
        }
        if (hasErrors())
            return reportAndExit(EVAL_PAGE);

        _state.disabled = isDisabled();

        //Create hidden field for state tracking
        ByRef ref = new ByRef();
        nameHtmlControl(_state, ref);

        if (hasErrors())
            return reportAndExit(EVAL_PAGE);

        // Only write out the hidden field if the select is not
        // disabled.  If it is disabled, then nothing will be posted
        // back from this.
        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
        if (!_state.disabled) {
            _hiddenState.clear();
            String hiddenParamName = null;
            hiddenParamName = _state.name + OLDVALUE_SUFFIX;
            _hiddenState.name = hiddenParamName;
            _hiddenState.value = "true";

            TagRenderingBase hiddenTag = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_HIDDEN_TAG, req);
            hiddenTag.doStartTag(writer, _hiddenState);
            hiddenTag.doEndTag(writer);
            write("\n");
        }

        // Render any formatting errors that may have occurred.
        if (fmtErrors != null)
            write(fmtErrors);


        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.SELECT_TAG, req);
        br.doStartTag(writer, _state);

        // Render the content of the body, these would be the options
        if (_saveBody != null) {
            write(_saveBody);
        }

        // if we are repeating then the body contained the options so we can exit here
        if (_repeater) {

            if (hasErrors())
                return reportAndExit(EVAL_PAGE);

            br.doEndTag(writer);
            if (!ref.isNull())
                write((String) ref.getRef());

            // Continue processing this page
            localRelease();
            return EVAL_PAGE;
        }

        // All of the code below will pass through the optionsDataSource, the dataSource and defaultValue and
        // create a full Select.
        if (_dynamicOptions != null) {
            if (_dynamicOptions instanceof Map) {
                Map dynamicOptionsMap = (Map) _dynamicOptions;
                Iterator keyIterator = dynamicOptionsMap.keySet().iterator();
                while (keyIterator.hasNext()) {
                    Object optionValue = keyIterator.next();
                    String optionDisplay = null;
                    if (dynamicOptionsMap.get(optionValue) != null) {
                        optionDisplay = dynamicOptionsMap.get(optionValue).toString();
                    }

                    if (optionValue != null) {
                        addOption(req, optionValue.toString(), optionDisplay);
                    }
                }
            }
            else if (_dynamicOptions instanceof Iterator) {
                Iterator dynamicOptionsIterator = (Iterator) evaluateOptionsDataSource();
                while (dynamicOptionsIterator.hasNext()) {
                    Object o = dynamicOptionsIterator.next();
                    if (o != null) {
                        String optionValue = o.toString();
                        addOption(req, optionValue, optionValue);
                    }
                }
            }
        }

        // add the value from the DataSource and Default value
        addDatasourceIfNeeded(req);
        addDefaultsIfNeeded(req);
        if (_nullable && !isMultiple()) {
            String txt = (_nullableOptionText != null) ? _nullableOptionText : "";
            addOption(req, NULL_VALUE, txt);
        }

        br.doEndTag(writer);
        if (!ref.isNull())
            write((String) ref.getRef());

        // Continue processing this page
        localRelease();
        return EVAL_PAGE;
    }
388336
def assert_element_not_visible(self, selector, by=By.CSS_SELECTOR,
                                   timeout=settings.SMALL_TIMEOUT):
        
        if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
            timeout = self.__get_new_timeout(timeout)
        self.wait_for_element_not_visible(selector, by=by, timeout=timeout)
        return True